Tabnine Logo
Thread.interrupted
Code IndexAdd Tabnine to your IDE (free)

How to use
interrupted
method
in
java.lang.Thread

Best Java code snippets using java.lang.Thread.interrupted (Showing top 20 results out of 13,662)

origin: google/guava

 @Override
 public void tearDown() {
  Thread.interrupted();
 }
});
origin: google/guava

 @Override
 public void tearDown() {
  Thread.interrupted();
 }
});
origin: google/guava

@Override
public void tearDown() throws Exception {
 super.tearDown();
 // TODO(cpovirk): run tests in other thread instead of messing with main thread interrupt status
 currentThread().interrupted();
 LocalCache.logger.removeHandler(logHandler);
}
origin: google/guava

 @Override
 public Boolean call() throws Exception {
  Object actual;
  if (allowInterruption) {
   actual = future.get();
  } else {
   actual = getUninterruptibly(future);
  }
  assertEquals(RESULT, actual);
  return Thread.interrupted();
 }
});
origin: ReactiveX/RxJava

@Test
public void interrupted() {
  Iterator<Object> it = Observable.never().blockingLatest().iterator();
  Thread.currentThread().interrupt();
  try {
    it.hasNext();
  } catch (RuntimeException ex) {
    assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException);
  }
  Thread.interrupted();
}
origin: ReactiveX/RxJava

@Test
public void interrupted() {
  Iterator<Object> it = Flowable.never().blockingLatest().iterator();
  Thread.currentThread().interrupt();
  try {
    it.hasNext();
  } catch (RuntimeException ex) {
    assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException);
  }
  Thread.interrupted();
}
origin: ReactiveX/RxJava

  @Override
  public void subscribe(ObservableEmitter<Boolean> emitter) throws Exception {
   emitter.onNext(Thread.interrupted());
   emitter.onComplete();
  }
})
origin: google/guava

@GwtIncompatible // Thread.interrupt
public void testGetUnchecked_interrupted() {
 Thread.currentThread().interrupt();
 try {
  assertEquals("foo", getUnchecked(immediateFuture("foo")));
  assertTrue(Thread.currentThread().isInterrupted());
 } finally {
  Thread.interrupted();
 }
}
origin: ReactiveX/RxJava

  @Override
  public void subscribe(FlowableEmitter<Boolean> emitter) throws Exception {
   emitter.onNext(Thread.interrupted());
   emitter.onComplete();
  }
}, BackpressureStrategy.MISSING)
origin: google/guava

@GwtIncompatible // threads
public void testSubmitAsync_asyncCallable_returnsInterruptedFuture() throws InterruptedException {
 assertThat(Thread.interrupted()).isFalse();
 SettableFuture<Integer> cancelledFuture = SettableFuture.create();
 cancelledFuture.cancel(true);
 assertThat(Thread.interrupted()).isFalse();
 ListenableFuture<Integer> future =
   submitAsync(constantAsyncCallable(cancelledFuture), directExecutor());
 assertThat(future.isDone()).isTrue();
 assertThat(Thread.interrupted()).isFalse();
}
origin: ReactiveX/RxJava

@Test
public void blockingGetErrorInterrupt() {
  final BlockingMultiObserver<Integer> bmo = new BlockingMultiObserver<Integer>();
  Thread.currentThread().interrupt();
  try {
    assertTrue(bmo.blockingGetError() instanceof InterruptedException);
  } finally {
    Thread.interrupted();
  }
}
origin: ReactiveX/RxJava

@Test
public void awaitTerminalEventInterrupt() {
  final TestSubscriber<Integer> ts = TestSubscriber.create();
  ts.onSubscribe(new BooleanSubscription());
  Thread.currentThread().interrupt();
  ts.awaitTerminalEvent();
  assertTrue(Thread.interrupted());
  Thread.currentThread().interrupt();
  ts.awaitTerminalEvent(5, TimeUnit.SECONDS);
  assertTrue(Thread.interrupted());
}
origin: ReactiveX/RxJava

@Test
public void awaitTerminalEventInterrupt() {
  final TestObserver<Integer> to = TestObserver.create();
  to.onSubscribe(Disposables.empty());
  Thread.currentThread().interrupt();
  to.awaitTerminalEvent();
  assertTrue(Thread.interrupted());
  Thread.currentThread().interrupt();
  to.awaitTerminalEvent(5, TimeUnit.SECONDS);
  assertTrue(Thread.interrupted());
}
origin: ReactiveX/RxJava

@Test
public void blockingGetErrorTimeoutInterrupt() {
  final BlockingMultiObserver<Integer> bmo = new BlockingMultiObserver<Integer>();
  Thread.currentThread().interrupt();
  try {
    bmo.blockingGetError(1, TimeUnit.MINUTES);
    fail("Should have thrown");
  } catch (RuntimeException ex) {
    assertTrue(ex.getCause() instanceof InterruptedException);
  } finally {
    Thread.interrupted();
  }
}
origin: ReactiveX/RxJava

@Test
public void blockingGetDefaultInterrupt() {
  final BlockingMultiObserver<Integer> bmo = new BlockingMultiObserver<Integer>();
  Thread.currentThread().interrupt();
  try {
    bmo.blockingGet(0);
    fail("Should have thrown");
  } catch (RuntimeException ex) {
    assertTrue(ex.getCause() instanceof InterruptedException);
  } finally {
    Thread.interrupted();
  }
}
origin: ReactiveX/RxJava

@Test
public void interrupt() {
  TestSubscriber<Integer> ts = new TestSubscriber<Integer>(0L);
  Thread.currentThread().interrupt();
  try {
    Flowable.just(1)
    .blockingSubscribe(ts);
    ts.assertFailure(InterruptedException.class);
  } finally {
    Thread.interrupted(); // clear interrupted status just in case
  }
}
origin: ReactiveX/RxJava

@Test
public void interrupted() {
  CountDownLatch cdl = new CountDownLatch(1);
  Disposable d = Disposables.empty();
  Thread.currentThread().interrupt();
  try {
    BlockingHelper.awaitForComplete(cdl, d);
  } catch (IllegalStateException ex) {
    // expected
  }
  assertTrue(d.isDisposed());
  assertTrue(Thread.interrupted());
}
origin: ReactiveX/RxJava

@Test
public void scheduleDirectInterrupt() {
  Thread.currentThread().interrupt();
  final int[] calls = { 0 };
  assertSame(EmptyDisposable.INSTANCE, Schedulers.trampoline().scheduleDirect(new Runnable() {
    @Override
    public void run() {
      calls[0]++;
    }
  }, 1, TimeUnit.SECONDS));
  assertTrue(Thread.interrupted());
  assertEquals(0, calls[0]);
}
origin: google/guava

 public final void run() {
  try {
   realRun();
   threadShouldThrow("InterruptedException");
  } catch (InterruptedException success) {
   threadAssertFalse(Thread.interrupted());
  } catch (Throwable t) {
   threadUnexpectedException(t);
  }
 }
}
origin: ReactiveX/RxJava

@Test
public void timeoutIndicated() throws InterruptedException {
  Thread.interrupted(); // clear flag
  TestSubscriber<Object> ts = Flowable.never()
  .test();
  assertFalse(ts.await(1, TimeUnit.MILLISECONDS));
  try {
    ts.assertResult(1);
    throw new RuntimeException("Should have thrown!");
  } catch (AssertionError ex) {
    assertTrue(ex.toString(), ex.toString().contains("timeout!"));
  }
}
java.langThreadinterrupted

Javadoc

Tests whether the current thread has been interrupted. The interrupted status of the thread is cleared by this method. In other words, if this method were to be called twice in succession, the second call would return false (unless the current thread were interrupted again, after the first call had cleared its interrupted status and before the second call had examined it).

A thread interruption ignored because a thread was not alive at the time of the interrupt will be reflected by this method returning false.

Popular methods of Thread

  • currentThread
  • sleep
    Causes the currently executing thread to sleep (temporarily cease execution) for the specified numbe
  • <init>
    Constructs a new Thread with no Runnable object, the given name and belonging to the ThreadGroup pas
  • start
    Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread
  • getContextClassLoader
    Returns the context ClassLoader for this Thread. The context ClassLoader is provided by the creator
  • interrupt
    Interrupts this thread. Unless the current thread is interrupting itself, which is always permitted,
  • setDaemon
    Marks this thread as either a #isDaemon thread or a user thread. The Java Virtual Machine exits when
  • getName
    Returns this thread's name.
  • join
    Waits at most millis milliseconds plus nanos nanoseconds for this thread to die. This implementatio
  • setContextClassLoader
    Sets the context ClassLoader for this Thread. The context ClassLoader can be set when a thread is cr
  • setName
    Changes the name of this thread to be equal to the argumentname. First the checkAccess method of thi
  • getStackTrace
    Returns an array of stack trace elements representing the stack dump of this thread. This method wil
  • setName,
  • getStackTrace,
  • getId,
  • isInterrupted,
  • isAlive,
  • setPriority,
  • yield,
  • getThreadGroup,
  • getPriority

Popular in Java

  • Reading from database using SQL prepared statement
  • runOnUiThread (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • findViewById (Activity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • BoxLayout (javax.swing)
  • JLabel (javax.swing)
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now