top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why thread sleep() and yield() methods are static in java?

0 votes
640 views
Why thread sleep() and yield() methods are static in java?
posted Feb 12, 2018 by Gn Guruswamy

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Thread sleep() and yield() methods work on the currently executing thread. So there is no point in invoking these methods on some other threads that are in wait state. That’s why these methods are made static so that when this method is called statically, it works on the current executing thread and avoid confusion to the programmers who might think that they can invoke these methods on some non-running threads.

answer Feb 13, 2018 by Frank Lee
...