works with blocking queues.