Causes the currently executing thread object to temporarily pause and allow other threads to execute.
which of the following will cause it to give up cycles to allow another thread to execute
Originally posted by Dave Winn:
I'm not sure that either of the answers listed is really correct. yield() will not definatelycause the JVM to chose a different thread. Rather, invoking yield() introduces the possibility that another thread wil be chosen by the JVM.
Originally posted by Dave Winn:
I'm making these assumptions:
1) yield() is a static method.
2) static methods can be called from null--i.e. null.yield() should compile.
So, to my mind there's no real difference between saying "null.yield();" and "this.yield()" and "Thread.yield();"
But, now that I think about that a little more, it occurs to me that there probably is some difference; otherwise, why would those different forms exist? But I don't know what the difference is, and i think this must be why i'm confused....could someone please set me right?
The strategy for method lookup depends on the invocation mode.
If the invocation mode is static, no target reference is needed and overriding is not allowed. Method m of class T is the one to be invoked.
SCJP2. Please Indent your code using UBB Code
SCJP2. Please Indent your code using UBB Code
Run away! Run away! Here, take this tiny ad with you:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|