public void releaseMailAccountForThread ( final MailAccount account ) { log . info ( "Releasing mail account for the current thread: {}" , account ) ; lock . lock ( ) ; try { ThreadReservationKeyWrapper wrapper = usedAccounts . get ( account ) ; if ( wrapper != null ) { if ( wrapper . thread == Thread . currentThread ( ) ) { log . debug ( "Releasing mail account: {}" , account ) ; usedAccounts . remove ( account ) ; condition . signalAll ( ) ; } else { log . warn ( "Cannot release a mail account reserved by a different thread: {}" , account ) ; } } } finally { lock . unlock ( ) ; } }
Releases the specified mail account for the current thread so it can be reused by another threads . Threads blocking on an attempt to reserved an account are notified .