当线程改变它的状态时会发生上下文切换吗?

Will context-switching happen when thread changes its state?

在java中,当线程改变其状态时是否会发生上下文切换?

我在谷歌上搜索了很多网站,但没有找到任何提到这方面的文章。

所以如果有人能提供帮助,我们将不胜感激。

像这样:

doSomething();
//when Thread.sleep() is called, thread state will change from runnable to timed_waiting, so will context switching happen?
Thread.sleep(1000);

是,sleep() 触发上下文切换到 TIMED_WAITING

参见:https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.State.html#TIMED_WAITING