The code would only execute
when someXThread was
executing, in which case telling someYThread to yield would be pointless. So since
the only thread worth calling yield on is the current thread, they make
the method static so you
won't waste time trying to call yield on
some
other thread
.
这是stackoverflow上的回答。是说,该代码只有在某个A线程执行时会被执行,这种情况下通知某个B线程yield是无意义的(因为B线程本来就没在执行)。因此只有当前线程执行yield才是有意义的。通过使该方法为static,你将不会浪费时间尝试yield 其他线程。
讲得很清楚,就是说,如果是和线程实例绑定的话,你可能会在当前线程中尝试调用otherThread.yeild()/sleep(), 而这使没有意义的