Locking, threads, notification and race conditions

Aren’t you talking about Condition (and the Windows’s equivalent Event) ?
Don’t re-invent the wheel, there is already WaitableEvent in juce.

Your first thread should do:
if (event1.wait())
{
take_lock
// process (whatever you want)
event2.signal();
event1.reset();
release_lock
}

The second/other thread should do
while (1) {
if (lock_tryenter)
{
event1.signal();
event2.reset();
// process
release_lock
event2.wait(infinite) // if you care about result of thread 1
}
else
{
event2.wait() // It’s set by thread 1 when it’s done processing
}
}