tag:blogger.com,1999:blog-694855878384792308.post3117548712326436772..comments2024-03-21T06:26:49.387-07:00Comments on Java67: How to pause a Thread in Java? Thread.sleep and TimeUnit.sleep Examplejavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-694855878384792308.post-80375767863569761872023-05-29T00:37:48.860-07:002023-05-29T00:37:48.860-07:00If you take a look at interrupt implementation, yo...If you take a look at interrupt implementation, you see synchronized block<br /><br />public void interrupt() {<br /> if (this != Thread.currentThread()) {<br /> checkAccess();<br /><br /> // thread may be blocked in an I/O operation<br /> synchronized (blockerLock) {<br /> Interruptible b = blocker;<br /> if (b != null) {<br /> interrupt0(); // set interrupt status<br /> b.interrupt(this);<br /> return;<br /> }<br /> }<br /> }<br /><br /> // set interrupt status<br /> interrupt0();<br /> }<br /><br />So, my point is wait() for delay is better and does not throws InterruptedException as interrupt() doAnonymousnoreply@blogger.com