• 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
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Thread guarantee ???

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At any time running thread can't have less priority than the thread which are in runnable state .

It will happen only if JVM is following priority based algorithem or time slicing algorithem .

So if any questiion come in exam related to first statement & nothing is specify about JVM , then what should be the answer ?

I hope question is clear .

thanks a lot .
 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i would select an answer which says behaviour is not guaranteed or that says something like "may print x or xx or xxx"
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in multithreading nothing is guaranteed except that all threads will get a chance to run (providing there's no deadlock and the JVM doesn't crash of course) at some point in time unless one thread enters an infinite loop and the JVM uses cooperative multitasking (hmm, is that a guarantee . )
 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

At any time running thread can't have less priority than the thread which are in runnable state



Not true... threads are subjected to the underlying threading model. For example, windows will try hard to give each thread a chance to execute that lower priority threads will run, even if a higher priority thread is in a runnable state.

in multithreading nothing is guaranteed except that all threads will get a chance to run



Not true... it is possible to starve a thread via using priority levels, under certain operating systems.

Henry
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I should have put an example for my question . Anyways here is the program :



I have executed this code 10 times , I am getting output the same ( first B 1000 times & then A 1000 times ) . Although I know that this is because my JVM is based on priority based algorithem . But the confusion is , in exam it will not be specified about JVM ( definately ) so what should be the answer .

I hope the question is clear .

thanks a lot .
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
---
i would select an answer which says behaviour is not guaranteed
---

adding to it: See we should make it clear SUN is going to conduct the exam to check ur proficiency for their JVM.

hope it makes sense
Thanks,
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Henry Wong:


Not true... it is possible to starve a thread via using priority levels, under certain operating systems.

Henry



But it would still run when the higher priority thread is somehow terminated with extreme prejudice
 
reply
    Bookmark Topic Watch Topic
  • New Topic