Forums Register Login

Threads-help

+Pie Number of slices to send: Send


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!!!
+Pie Number of slices to send: Send
Ok Shilpa, I'd just added few more messages in your code, can you run it
and see how it works?

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 881 times.
Similar Threads
Mock Blues 1
can anybody tel me wat exactly Thread.start() will do?
How setDaemon works
Threads
Creating threads using inner classes
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:24:41.