• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to stop Thread  RSS feed

 
sudhakar ananth
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends

See i have 4 classes in a module,it is somewhat interlinked .

in a particular class i need to end the particular thread(that class) without comming out of whole application and go to other class..

if i use System.exit(); i am ending the thread and as well as i ending whole application.....

but i need only to that particular thread.not the whole program..

thank you very much....
bye..
 
Tor Henning Post
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The thread you want to stop, is that running a everlasting loop like



you could have the thread check a flag like this.

 
sudhakar ananth
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you,
Very Friend, i will try this...
bye..
 
Chris Hurst
Ranch Hand
Posts: 443
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
errrr .... no ....



You need a memory barrier for running e.g. make it volatile use some synchornization, otherwise the other thread might not see running set to false if cached i.e. it might never stop.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!