wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes A Very Tough Question from JDiscuss Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "A Very Tough Question from JDiscuss" Watch "A Very Tough Question from JDiscuss" New topic
Author

A Very Tough Question from JDiscuss

Andy Jav
Greenhorn

Joined: Jun 01, 2005
Posts: 3
Can someone give the output for this code without actually compiling & running ? This is a question from JDiscuss Test 4 with a little twist.

[ July 07, 2005: Message edited by: Barry Gaunt ]
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

Can someone give the output for this code without actually compiling & running ?
My first reaction is that actually compiling and running it won't help either. Not only should you not depend on the thread scheduler for behavior, you won't see this type of question on the SCJP.

Furthermore, it seems a little pointless to ask others to give you the output of the code. Do you have a question about it? Is it doing something you don't expect?

<EDIT>
In case I wasn't clear about "running won't help" - there's no way to know what the output of that code will be. It can vary from one run to the next.
[ July 06, 2005: Message edited by: Steve Morrow ]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Please use tags around code to preserve its formatting.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: A Very Tough Question from JDiscuss
 
Similar Threads
wait() and notifyAll()
join() method in Thread doesn't work as expected
threading issue
Synchronizing between two threads, one implements Runnable the other extends Thread
threading issue