jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes Practice Exam I: question 1 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 » Java » Beginning Java
Bookmark "Practice Exam I: question 1" Watch "Practice Exam I: question 1" New topic

Practice Exam I: question 1

henry joe

Joined: Jul 24, 2012
Posts: 16
Hello the answer given to the code below says that Bang will execute for a second or two and It's difficult to predict which thread will be the last to finish. My question is how did they come to such conclusions from the code below? I had thought that it will execute for around 2 and half seconds ..

I just need explanations on why it is difficult to predict which thread and also the time factor in threads. Thanks
Henry Wong

Joined: Sep 28, 2004
Posts: 18545

Please QuoteYourSources.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
henry joe

Joined: Jul 24, 2012
Posts: 16
OCP Java Practice Exam textbook ; Practice Exam I question 1
LQ McDonald III

Joined: Aug 01, 2012
Posts: 10

Well...it could be because java does not explicitly enforce thread scheduling in any specific manner and lacks a thread scheduler. Thread scheduling in Java is platform dependent and relies on your JVM implementation.
Don't get me started about those stupid light bulbs.
subject: Practice Exam I: question 1
Similar Threads
Output even more unexpected than I was expecting!
isInterrupted() or interrupted() !!!!
Doubt on a thread question from K&B OCP Practice Exams
About Synchronization concept of static and non static method using Class level lock
about threads, using locks of the objects in synchronized blocks