• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

yied() method

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
JQPlus question:test2/threads/q4
What is guaranteed by the JVM about the method yield()?

I have answered:
"The current thread will sleep for some time giving a chance to other threads to run."
The good answer:
"Nothing is guaranteed."
How that, in jdk1.2:yield
"public static void yield()
Causes the currently executing thread object to temporarily pause and allow other threads to execute."?
So no word about best-effort or something like that.
So how is it?
Thanks,
Cristian
 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Cristian Negresco:
Hi,
JQPlus question:test2/threads/q4
What is guaranteed by the JVM about the method yield()?

I have answered:
"The current thread will sleep for some time giving a chance to other threads to run."
The good answer:
"Nothing is guaranteed."
How that, in jdk1.2:yield
"public static void yield()
Causes the currently executing thread object to temporarily pause and allow other threads to execute."?
So no word about best-effort or something like that.
So how is it?
Thanks,
Cristian



Yes. Nothing is guaranteed
Reason being that, yield() will only yield if there are any threads that needs to be executed like a highpriority thread or so. Its not mandatory for the current thread to sleep and let the other threads to let run...since it(ie JVM) implementation specific
Ragu
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following is a link to a search made in this forum for all threads about yield, that topic is heavily discussed here and information is made to be reused, so browse around and tell us if you did not find what you want.
http://www.javaranch.com/cgi-bin/ubb/search.cgi?action=simplesearch&StartPoint=121&SearchTerms=yield&SearchUser=&ForumChoice=24&SearchIn=ALL&SearchDate=ALL&ExactName=no&BooleanAND= YES&File=temp-2452214-112955-IHIB.cgi&Continue=False
Just copy paste since UBB doesn't seem to work here...
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
[This message has been edited by Valentin Crettaz (edited October 31, 2001).]
[This message has been edited by Valentin Crettaz (edited October 31, 2001).]
 
Cristian Negresco
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks Ragu and Valentin, now it is clear.
..Cristian
 
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic