public static boolean sendMail ( MailItem item ) { LOGGER . debug ( "Mail : " + item . toString ( ) ) ; boolean result = queue . add ( item ) ; LOGGER . info ( "Adding mail to queue. Queue size: " + queue . size ( ) ) ; // If thread is alive leave the job to it // Else create new thread and start. if ( ! consumerThread . isAlive ( ) ) { consumerThread = new Thread ( consumer ) ; consumerThread . start ( ) ; } return result ; }
Takes the mail item into the queue and manages the mail sender thread . If thread is alive it will send the mail at the end of current thread queue . Else a new thread will be created and started .