my $Buffer; #The buffer that needs to be filled. push(@Que, \$Buffer); #Put the buffer into the que, this is a line I put in for simplicty, the actual request is a lot more complicated. while (1) #Infinite loop { threads->yield(); #Yield each iteration lock($Buffer); #Lock the buffer, this way if data is still being placed intot eh buffer in the other thread it will be locked there and we cannot get data early. will it be unlocked for the next iteration? or is the loop not considered leaving it's own {} per iteration? last if ($Buffer); #If the buffer is filled continue. }