This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Thread Starvation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Thread Starvation" Watch "Thread Starvation" New topic
Author

Thread Starvation

Joe Stewart
Greenhorn

Joined: Dec 09, 2004
Posts: 6
Andrew,

The starvation example in your book works different on my system (SuSe Linux 10.0). The starvation thread always runs, and in about forty trys, thread four never ran. Do you have any idea why?

It appears that my JVM runs the threads in order, almost every time, like so:

Starvation Thread: is working 10
Starvation Thread: is working 9
Starvation Thread: is working 8
Starvation Thread: is working 7
Starvation Thread: is working 6
Starvation Thread: is working 5
Starvation Thread: is working 4
Starvation Thread: is working 3
Starvation Thread: is working 2
Starvation Thread: is working 1
Thread-2: is working 10
Thread-2: is working 9
Thread-2: is working 8
Thread-2: is working 7
Thread-3: is working 10
Thread-3: is working 9
Thread-3: is working 8
Thread-3: is working 7
Thread-3: is working 6
Thread-3: is working 5
Thread-3: is working 4
Thread-3: is working 3
Thread-3: is working 2
Thread-3: is working 1

The thread priority seems to have no effect on the starvation thread.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Joe,

I will have to check into this - I don't know why you are getting different results. I will check this on RedHat Linux a bit later and see what I get, and look at the Sun documentation on green threads.

Are you using Sun's JVM, or one of the other JVMs?

Regardless, I think you are still seeing the results of starvation, even if it was not the desired effect - that is, in your case, thread 4 starved.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Joe Stewart
Greenhorn

Joined: Dec 09, 2004
Posts: 6
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
 
Consider Paul's rocket mass heater.
 
subject: Thread Starvation
 
Similar Threads
29th Nov Bonus Puzzle
Another thread question
IT Market in Australia, Singapore, UK, USA...
Expalin the answer -- Arrays
a query regarding 'for' loop