permaculture playing cards*
The moose likes Threads and Synchronization and the fly likes suspend resume.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "suspend resume.." Watch "suspend resume.." New topic
Author

suspend resume..

Ramdas Sawant
Ranch Hand

Joined: Aug 08, 2005
Posts: 51
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


If you think you can, you can. If you think you can't, you are right.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19064
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19064
    
  40

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
Ramdas Sawant
Ranch Hand

Joined: Aug 08, 2005
Posts: 51
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: suspend resume..