Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

suspend resume..

 
R Sawant
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,
Go through the following code



The o/p is "In run". Why the thread do not resume even after the call to resume(). I know both the methods are depricated but still curious about the o/p. Plz explain.

Thanks,
Ramdas
 
Henry Wong
author
Marshal
Pie
Posts: 21212
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ramdas Sawant:

The o/p is "In run". Why the thread do not resume even after the call to resume(). I know both the methods are depricated but still curious about the o/p. Plz explain.


How does the thread call the resume() method, once it has been suspended? ...

Henry
 
Henry Wong
author
Marshal
Pie
Posts: 21212
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW, prior to these methods being deprecated, they were not being used this way. These methods were used by a thread to suspend / resume another thread -- not itself.

Which leads to the next question. Why were they deprecated? The reason it was deprecated is because it was not possible to confirm that the *other* thread was doing anything safe. It could suspend while holding a very important lock, including a system lock.

Henry
 
R Sawant
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Henry,
Thanks mate. I should have thought more, instead of posting the question on the forum. I need to really improve on threads. Thanks once again.

Regards,
Ramdas.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic