This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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!!!
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