Here you can find the source of sleepCheck(int timeout, AtomicBoolean flag)
public static void sleepCheck(int timeout, AtomicBoolean flag) throws InterruptedException
//package com.java2s; //License from project: Apache License import java.util.concurrent.atomic.AtomicBoolean; public class Main { public static void sleepCheck(int timeout, AtomicBoolean flag) throws InterruptedException { int timer = 0; while (timer < timeout) { Thread.sleep(1000);//from w ww.j a v a2s.c o m timer++; if (flag.get()) throw new InterruptedException("Interrupt Request Received"); } } }