Minor: documentation for Thread::sleep()

The static Thread::sleep() method has no documentation at the moment.

While it is quite straightforward to understand what it does in essence (pause execution of the current thread for the specified amount of milliseconds), I think that would also be a good place where to explain the difference between sleep() and wait(), and perhaps give some rules of thumb for when to use one or the other.

7 Likes

Took the occasion of another “like” given to the post above, to bump the topic gently for the @juce team to notice

Wait() and notify() work together. Currently I’m using wait to pause a thread from looping after doing a short task. IF I use sleep(0) in a while loop checking for a go signal (a Boolean), it will take much longer. wait(-1) pauses the thread forever UNTIL a notify is called from the task needing threads work. A very short answer, sorry. There are of course safeguards and checks for threading ending to consider.

I’ve clarified some of the docs here:

1 Like

Ah yes @DaveH, thanks, I am aware of all of those subtleties, but thanks for clarifying.
That’s exactly the type of information that should have gone into the doc for those methods, which was the point of my original post.
I’m glad that the doc has been improved now, good job @ed95 !