Reputation: 133
It's all in the title, really.
I know Thread.sleep()
only makes the current thread sleep, but is there a way to force all threads to sleep simultaneously, or would that be down to self-management?
Upvotes: 1
Views: 2439
Reputation: 5552
The answer is simple : there is no way to make all the thread sleep from Java (from the inside of the application).
Moreover, on Java, there is a lot of internal thread (like GC thread, Finalization thread, ... ) that you cannot manipulate so "all" will never be possible.
Regards,
Loïc
Upvotes: 3
Reputation: 8851
It would be dangerous to put thread into sleep from outside, since it can be currently in some intermediate state (that's the reason why it's not good to kill thread from outside, for example). So please make it via self-management.
Upvotes: 3