/** * Swap the current thread's active interrupt handler. Most callers should restore the old handler in a {@code finally} * block like this: * <pre> * InterruptHandler oldHandler = JBossThread.getAndSetInterruptHandler(newHandler); * try { * ...execute interrupt-sensitive operation... * } finally { * JBossThread.getAndSetInterruptHandler(oldHandler); * } * </pre> * * @param newInterruptHandler the new interrupt handler * @return the old interrupt handler */ public static InterruptHandler getAndSetInterruptHandler(final InterruptHandler newInterruptHandler) { final JBossThread thread = currentThread(); if (thread == null) { throw Messages.msg.noInterruptHandlers(); } try { return thread.interruptHandler; } finally { thread.interruptHandler = newInterruptHandler; } }
/** * Swap the current thread's active interrupt handler. Most callers should restore the old handler in a {@code finally} * block like this: * <pre> * InterruptHandler oldHandler = JBossThread.getAndSetInterruptHandler(newHandler); * try { * ...execute interrupt-sensitive operation... * } finally { * JBossThread.getAndSetInterruptHandler(oldHandler); * } * </pre> * * @param newInterruptHandler the new interrupt handler * @return the old interrupt handler */ public static InterruptHandler getAndSetInterruptHandler(final InterruptHandler newInterruptHandler) { final JBossThread thread = currentThread(); if (thread == null) { throw Messages.msg.noInterruptHandlers(); } try { return thread.interruptHandler; } finally { thread.interruptHandler = newInterruptHandler; } }
/** * Swap the current thread's active interrupt handler. Most callers should restore the old handler in a {@code finally} * block like this: * <pre> * InterruptHandler oldHandler = JBossThread.getAndSetInterruptHandler(newHandler); * try { * ...execute interrupt-sensitive operation... * } finally { * JBossThread.getAndSetInterruptHandler(oldHandler); * } * </pre> * * @param newInterruptHandler the new interrupt handler * @return the old interrupt handler */ public static InterruptHandler getAndSetInterruptHandler(final InterruptHandler newInterruptHandler) { final JBossThread thread = currentThread(); if (thread == null) { throw Messages.msg.noInterruptHandlers(); } try { return thread.interruptHandler; } finally { thread.interruptHandler = newInterruptHandler; } }