Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

22
  • 11
    this is exactly what shutdown / awaitTermination are meant for Commented Aug 9, 2009 at 14:31
  • 42
    It is a good pattern if this task handling is a one-time event. If this is done repeatedly during the same runtime, however, it is not optimal, as you would create and tear down threads repeatedly every time it is executed. Commented Aug 9, 2009 at 16:25
  • 51
    I'm looking for any official documentation that Long.MAX_VALUE, TimeUnit.NANOSECONDS is equivalent to not having a timeout. Commented Aug 22, 2012 at 14:04
  • 20
    I can't believe that you have to use shutdown in order to join on all the current threads (after using shutdown, you cannot use the executor again ever). Suggest using list of Future's instead... Commented Nov 2, 2012 at 16:02
  • 25
    @SamHarwell see the java.util.concurrent package documentation under the Timing section: To wait "forever", you can use a value of Long.MAX_VALUE Commented Aug 28, 2015 at 22:01