• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread Starvation

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
reply
    Bookmark Topic Watch Topic
  • New Topic