/** * Returns an NGSession to the pool. The pool may choose to shutdown * the thread if the pool is full * @param session the NGSession to return to the pool */ void give(NGSession session) { boolean shutdown = false; synchronized(lock) { if (done || poolEntries == poolSize) { shutdown = true; } else { pool[poolEntries] = session; ++poolEntries; } } if (shutdown) session.shutdown(); }
/** * Shuts down the pool. Running nails are allowed to finish. */ void shutdown() { done = true; synchronized(lock) { while (poolEntries > 0) { take().shutdown(); } } }
sessionOnDeck.shutdown();