This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads-help

 
shilpa Reddy
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 243
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic