This week's book giveaway is in the Java in General forum. We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line! See this thread for details.
There is no version of yield in Thread which allows you to specify a time or Thread instance.
The documentation for yield says
Causes the currently executing thread object to temporarily pause and allow other threads to execute.
The reason that both 1 and 2 will work is that yield is a static method in Thread.
So you can call the method using an instance of Thread, but it is irrelevant which Thread instance calls it. The currently executing thread is the thread that pauses. [ February 16, 2007: Message edited by: Keith Lynn ]
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop