Implement a waiting method for state masks in Thread
This feature would be very useful for Supervisor, for example.