2 Mayıs 2019 Perşembe

Uninterruptibles Sınıfı

awaitInterruptibly metodu
Metodun içi şöyle
public static boolean awaitUninterruptibly(Condition condition, long timeout,
TimeUnit unit)
{ boolean interrupted = false; try { long remainingNanos = unit.toNanos(timeout); long end = System.nanoTime() + remainingNanos; while (true) { try { return condition.await(remainingNanos, NANOSECONDS); } catch (InterruptedException e) { interrupted = true; remainingNanos = end - System.nanoTime(); } } } finally { if (interrupted) { Thread.currentThread().interrupt(); } } }
sleepUninterruptibly metodu
Şöyle yaparız
Uninterruptibles.sleepUninterruptibly(1000, TimeUnit.MILLISECONDS);

Hiç yorum yok:

Yorum Gönder