public ReceivedMessageTask getTaskToProcess ( ) { ReceivedMessageTask task = tasks . peek ( ) ; if ( task != null && task . setProcessing ( ) ) { return task ; } return null ; }
Gets first task from queue if it can be processed . If first task is already in process it returns null .