aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads-help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads-help" Watch "Threads-help" New topic
Author

Threads-help

shilpa Reddy
Ranch Hand

Joined: Jul 26, 2006
Posts: 42


what will be the result of the above program.....wat is the order of the sysout. can you please explain them....after a start() command will the thread execute the sysout below it or will dit skip that and invoke the run method...wat is the order of execution....please explain....thanks in advance!!!
Vijay Vaddem
Ranch Hand

Joined: Feb 13, 2004
Posts: 243
Ok Shilpa, I'd just added few more messages in your code, can you run it
and see how it works?

shilpa Reddy
Ranch Hand

Joined: Jul 26, 2006
Posts: 42
vijay the problem is im in office now n cant run it now.....im having my exam day after....so if you can give the output n explain it in words ...it wuld be really really helpfull
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

After t.start() is called, r's run method can be executed at the platform's discretion. It's unlikely that run will be invoked immediately after the start call (prior to the next line in the current thread), but it's possible.

No lines are "skipped." After 'r' is given a chance to run, the main thread will resume where it left off.

IMPORTANT EXAM TIP: Note that sleep is a static method in Thread. It puts the current thread to sleep, even if called through some other Thread instance. For example, in this code, when you call t.sleep, you are not putting t to sleep -- you are just calling Thread.sleep by way of t.


"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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threads-help