File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Starvation

 
Joe Stewart
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11833
181
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Joe Stewart
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic