@Override protected void beforeExecute(Thread t, Runnable r) { ((WorkerThreadImpl) t).createByteBuffer(false); }
/** * Method invoked prior to executing the given Runnable in the * given thread. This method is invoked by thread <tt>t</tt> that * will execute task <tt>r</tt>, and may be used to re-initialize * ThreadLocals, or to perform logging. * * <p>This implementation does nothing, but may be customized in * subclasses. Note: To properly nest multiple overridings, subclasses * should generally invoke <tt>super.beforeExecute</tt> at the end of * this method. * * @param t the thread that will run task r. * @param r the task that will be executed. */ protected void beforeExecute(Thread t, Runnable r) { if (t instanceof WorkerThreadImpl) ((WorkerThreadImpl) t).createByteBuffer(false); }
public ThreadAttachment detach() { ThreadAttachment currentAttachment = getAttachment(); int mode = currentAttachment.getMode(); updateAttachment(mode); // Re-create a new ByteBuffer if ((mode & Mode.BYTE_BUFFER) != 0) { createByteBuffer(true); } if ((mode & Mode.SSL_ENGINE) != 0) { sslEngine = null; } if ((mode & Mode.INPUT_BB) != 0) { inputBB = null; } if ((mode & Mode.OUTPUT_BB) != 0) { outputBB = null; } // Switch to the new ThreadAttachment. this.threadAttachment = null; currentAttachment.deassociate(); return currentAttachment; }