in reply to need a thread to wait until a buffer is full.

I don't think you're understanding the semantics of lock. When you call lock on a locked variable the call blocks until the lock is freed. Every loop iteration is its own lexical scope, so when you fall off the end locks are freed. Your comments say that the other thread won't unlock the $Buffer until after its full, so the last if ($Buffer); to continue on your program is unnecessary unless your semantics differ from what you've told us. To ensure timely lock freeing you can use bare blocks:

#initialize... { lock($Buffer); # We've got the lock # Do stuff } # Fall off the end of our enclosing scope

Also for your queue have you considered using a Thread::Queue if $Buffer is a string buffer this will be easier than dealing with making sure locks are controlled properly. If the filling thread fills it before relinquishing the lock then instead of mucking with the locks push the full buffer into the queue and then the processor of these buffers just dequeues the full buffers and acts on them. The dequeue method simply waits for data, and you can have multiple threads waiting on a Queue so your processing thread (if it doesn't require atomic output or something) can have multiple (number of cores + 1) instances processing.