Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Some threading issues !!

 
Saurabh Agrawal
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends ,
I have some doubts about the threads .So i hope you guys help me out in that for interview :
1) How many threads we can create ?
2)How do thread's stop method work ? Can i restart my stopped thread ?
3) if i create a thread & then null ou the reference to it, what happens to the thread ? does it get interrupted or what ?
4) how should i stop a thread so that i can start a new thread in its place ?
Hoping to hear from you soon,
Thanks,
Saurabh
 
Magnus Andersson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. As many as you want. Not recommended with too many though.
2. stop is deprecated and should not be used
3. The thread will continue to execute even if you null the reference. When the thread is finished, it will be collected by garbage collector.
4. Let the thread finish, don't stop it. If you want to stop it, make a boolean while(shouldRun) { //loop} and set the shouldRun flag to false to let the thread finish.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic