Avoid waking up threads sleeping on STM more than once

Opening a pull request to track further discussion.

Nothing appears to regress on the testsuite. How should we proceed?