chrisssss
chrisssss

Reputation: 35

Will context-switching happen when thread changes its state?

In java, will context switching happen when thread is changing its state?

I've googled a lot of sites, but did't find any article mentioned about this.

so if anyone can help would be appreciated.

like this:

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

Upvotes: 1

Views: 198

Answers (1)

Marco R.
Marco R.

Reputation: 2720

Yes, sleep() triggers context switching to TIMED_WAITING.

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

Upvotes: 0

Related Questions