Nicer sleep() With TimeUnit

import java.util.concurrent.TimeUnit;
      try {
        } catch (InterruptedException ex) {}

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home:

NEW online workshop: WebStandards Igniter (online)

Airport MUC workshops: Java EE 7: Bootstrap, Effective, Architectures, Web, React and Angular, Testing and Microservices

Podcast: and newsletter:

A book about rethinking Java EE Patterns


sleep as a method of TimeUnit, is this OOP? I would rather like to have Thread.sleep(Duration)

Posted by asd on December 17, 2015 at 11:29 PM CET #

I once saw in a JavaOne session that there is a sleep method in some JDK class that does not throw an InterruptedException. Do you know which class it is?

Posted by Juan on October 21, 2016 at 01:17 AM CEST #

What about sleep in JEE environments?
As already stated in one must not manage Threads, and sleep is a managing action, even if you use it through TimeUnit (which effectively calls Thread.sleep).

I've seen proposals to use Timers, but that's a big overhead if you just want to have a very small delay between retries with unstable resources.

Posted by Daniel on February 09, 2017 at 09:26 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments