1. A method of processing a task, the method comprising the steps of: processing the task by a producer thread and a consumer thread running concurrently, each thread executing at least a portion of the task, the threads communicating via a message queue comprising a plurality of messages produced by the producer thread to be processed by the consumer thread; detecting an oscillation between a substantially full and a substantially empty state of the message queue, wherein the state of the message queue is determined based on the plurality of messages in the message queue to be processed by the consumer thread; and in the event of detecting the oscillation, processing the task sequentially by a single thread.