I\'m looking for a way to block until a BlockingQueue is empty.
I know that, in a multithreaded environment, as long as there are producers putting items in
It's not quite what you want to do, but using a SynchronousQueue would have a very similar effect as your Java/Pseudocode, namely the producer blocking until all of the data has been retrieved by some consumer.
Only difference being the producer blocking on each put until a consumer comes to retrieve the data, instead of only once at the end. Not sure if that would make a difference in your case. I'd expect it to only make a noticeable difference, if the task performed by the producer is somewhat expensive.