ANs:"in run" can you explain how I know as suspend() and resume() are not in use lately ,how will I get output as "in run last run".
2:
Can anyone explain join() and how it works, I had read Books but not able to get much please explain?
EDIT by mw: Added much-needed Code Tags. Please use these in the future. Also, made the subject line more descriptive than simply "Threads." [ January 22, 2007: Message edited by: marc weber ]
Well, it's a bit stronger than "not in use lately." These methods are deprecated because suspend is deadlock prone, and resume is only for use with suspend. For details, see JavaThread Primitive Deprecation, which illustrates how to use wait and notify instead.
The join method delays execution of the calling thread until the indicated thread completes. In this case, the main thread is "joined" to t1, which means the call to t2.start() and the println of "End" will not execute until t1 completes. Comment out the join line and note the difference in output.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Originally posted by marc weber: These methods are deprecated because suspend is deadlock prone, and resume is only for use with suspend. For details, see Java Thread Primitive Deprecation, which illustrates how to use wait and notify instead.
While I agree with Marc, that the suspend() and resume() methods, can deadlock, that is not the cause in this example.
In the example, you are causing the "boo" thread to suspend itself, by having it call the suspend() method. Then you are expecting this suspended thread to resume itself by calling the resume() method. How can a suspended thread (not running thread), call the resume() method?