public Runnable associateWith(Runnable runnable) { if (runnable instanceof Thread) { String msg = "This implementation does not support Thread arguments because of JDK ThreadLocal " + "inheritance mechanisms required by Shiro. Instead, the method argument should be a non-Thread " + "Runnable and the return value from this method can then be given to an ExecutorService or " + "another Thread."; throw new UnsupportedOperationException(msg); } return new SubjectRunnable(this, runnable); }
/** * {@link ThreadState#bind Bind}s the Subject thread state, executes the target {@code Runnable} and then guarantees * the previous thread state's {@link ThreadState#restore restoration}: * <pre> * try { * threadState.{@link ThreadState#bind bind()}; * {@link #doRun doRun}(targetRunnable); * } finally { * threadState.{@link ThreadState#restore restore()} * } * </pre> */ public void run() { try { threadState.bind(); doRun(this.runnable); } finally { threadState.restore(); } }
public Runnable associateWith(Runnable runnable) { if (runnable instanceof Thread) { String msg = "This implementation does not support Thread arguments because of JDK ThreadLocal " + "inheritance mechanisms required by Shiro. Instead, the method argument should be a non-Thread " + "Runnable and the return value from this method can then be given to an ExecutorService or " + "another Thread."; throw new UnsupportedOperationException(msg); } return new SubjectRunnable(this, runnable); }
/** * {@link ThreadState#bind Bind}s the Subject thread state, executes the target {@code Runnable} and then guarantees * the previous thread state's {@link ThreadState#restore restoration}: * <pre> * try { * threadState.{@link ThreadState#bind bind()}; * {@link #doRun doRun}(targetRunnable); * } finally { * threadState.{@link ThreadState#restore restore()} * } * </pre> */ public void run() { try { threadState.bind(); doRun(this.runnable); } finally { threadState.restore(); } }
@Override public Runnable associateWith(final Runnable runnable) { return new SubjectRunnable(this, runnable); }
/** * {@link ThreadState#bind Bind}s the Subject thread state, executes the target {@code Runnable} and then guarantees * the previous thread state's {@link ThreadState#restore restoration}: * <pre> * try { * threadState.{@link ThreadState#bind bind()}; * {@link #doRun doRun}(targetRunnable); * } finally { * threadState.{@link ThreadState#restore restore()} * } * </pre> */ public void run() { try { threadState.bind(); doRun(this.runnable); } finally { threadState.restore(); } }
public Runnable associateWith(Runnable runnable) { if (runnable instanceof Thread) { String msg = "This implementation does not support Thread arguments because of JDK ThreadLocal " + "inheritance mechanisms required by Shiro. Instead, the method argument should be a non-Thread " + "Runnable and the return value from this method can then be given to an ExecutorService or " + "another Thread."; throw new UnsupportedOperationException(msg); } return new SubjectRunnable(this, runnable); }