List of usage examples for java.lang InterruptedException InterruptedException
public InterruptedException()
InterruptedException
with no detail message. From source file:Main.java
public static void checkInterrupted() throws InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); }//www. j a v a 2s . co m }
From source file:Main.java
public static void interruptCheck() throws InterruptedException { if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); }/* www .j a v a2 s.co m*/ }
From source file:Main.java
/** * If the thread has been interrupted, throws an InterruptedException. *//*from ww w. j a va 2s . co m*/ public static void checkForInterruption() throws InterruptedException { if (Thread.currentThread().isInterrupted()) throw new InterruptedException(); }
From source file:Main.java
/** * Checks if the current thread /*from ww w . j ava2 s. c o m*/ * * @throws InterruptedException if the current thread was interrupted */ public static void checkIfInterrupted() throws InterruptedException { // make this thread interruptible, if called from SwingWorker if (Thread.interrupted()) { throw new InterruptedException(); } }
From source file:Main.java
public static void checkInterruptedStatus() throws InterruptedException { if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); }/*from w w w .ja va 2 s . c o m*/ }
From source file:Main.java
public static void sleepNanos(long nanoDuration) throws InterruptedException { final long end = System.nanoTime() + nanoDuration; long timeLeft = nanoDuration; do {//from w ww . ja v a 2 s. c o m if (timeLeft > SLEEP_PRECISION) { Thread.sleep(1); } else if (timeLeft > SPIN_YIELD_PRECISION) { Thread.sleep(0); } timeLeft = end - System.nanoTime(); if (Thread.interrupted()) throw new InterruptedException(); } while (timeLeft > 0); }
From source file:Main.java
private static void throwExceptionIfInterruptedOrCancelled(AtomicBoolean isCanceled) throws InterruptedException { if (Thread.interrupted() || (isCanceled != null && isCanceled.get())) { throw new InterruptedException(); }/*from ww w . ja v a2s . c o m*/ }
From source file:net.wimpi.telnetd.util.ReentrantLock.java
public void acquire() throws InterruptedException { //log.debug("acquire()::" + Thread.currentThread().toString()); if (Thread.interrupted()) throw new InterruptedException(); Thread caller = Thread.currentThread(); synchronized (this) { if (caller == m_Owner) ++m_Holds;/*from w w w . j ava2 s .co m*/ else { try { while (m_Owner != null) wait(); m_Owner = caller; m_Holds = 1; } catch (InterruptedException ex) { notify(); throw ex; } } } }
From source file:PiInterrupt.java
private void calcPi(double accuracy) throws InterruptedException { latestPiEstimate = 0.0;// www . j av a 2s .c om long iteration = 0; int sign = -1; while (Math.abs(latestPiEstimate - Math.PI) > accuracy) { if (Thread.interrupted()) { throw new InterruptedException(); } iteration++; sign = -sign; latestPiEstimate += sign * 4.0 / ((2 * iteration) - 1); } }
From source file:SwingWorkerProcessor.java
@Override protected Integer doInBackground() throws Exception { int sum = 0;// www.j ava 2 s.c o m for (int counter = 1; counter <= iteration; counter++) { sum = sum + counter; this.publish(counter); if (Thread.interrupted()) { throw new InterruptedException(); } if (this.isCancelled()) { break; } Thread.sleep(intervalInMillis); } return sum; }