/** * Checks for user cancellation or thread interruption. In any of those both cases, {@link * TaskInterruptedException} * is thrown that might be caught and handled by caller. If not handled, thread will die-off. If handled, caller * must ensure and handle interrupt flag of current thread. */ public static void checkInterruption() throws TaskInterruptedException { Thread.yield(); if (getCurrentProgressListener().isCanceled()) { throw new TaskInterruptedException("Thread \"" + Thread.currentThread().getName() + "\" is canceled!", true); } if (Thread.interrupted()) { throw new TaskInterruptedException("Thread \"" + Thread.currentThread().getName() + "\" is interrupted!", false); } } }
/** * Checks for user cancellation or thread interruption. In any of those both cases, {@link TaskInterruptedException} * is thrown that might be caught and handled by caller. If not handled, thread will die-off. If handled, caller * must ensure and handle interrupt flag of current thread. */ public static void checkInterruption() throws TaskInterruptedException { Thread.yield(); if ( getCurrentProgressListener().isCanceled() ) { throw new TaskInterruptedException( "Thread \"" + Thread.currentThread().getName() + "\" is canceled!", true ); } if ( Thread.interrupted() ) { throw new TaskInterruptedException( "Thread \"" + Thread.currentThread().getName() + "\" is interrupted!", false ); } } }
throw new TaskInterruptedException( "Thread \"" + Thread.currentThread().getName() + "\" is interrupted!", false );