Fix thread_notify. Clarify semantics for thread_finished/running.

thread_notify now registers a flag so that a notify when the thread
is already awake will force the thread to skip its next sleep in order
to avoid a race condition in the "check condition variable, sleep" cycle
when a thread could be notified in between the check and the sleep,
thereby never waking. The previous fix, thread_inhibit, was clumsy.
Add thread notify/sleep test cases
implement a (broken) notify test (for later)
Remove broken test