• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

why thread priority is not working here

 
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


i ran tis program for many times but it is not displaying according to threads priority?
why?
 
Ranch Hand
Posts: 1249
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by saikrishna cinux:

i ran tis program for many times but it is not displaying according to threads priority?
why?



Well I run this program on my m/c I got output according to the expectaions. I am giving here output on my m/c

Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]
Thread[thread two,10,main]
Thread[thread three,5,main]
Thread[thread one,1,main]



Well I think it's according to your expectations, what you was expecting could you let me know.....

according to your code..



th2 is with MAX_PRIORITY
th3 is then and at last is
th1
[ September 26, 2006: Message edited by: Ankur Sharma ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While a thread sleeps, other threads are allowed to execute. Priority only comes into play when two threads try to do something at the same time, which is not guaranteed to happen at all for our example.

Moving to our threads forum...
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic