< prev index next >

jdk/src/jdk.jline/share/classes/jdk/internal/jline/internal/ShutdownHooks.java

Print this page


   1 /*
   2  * Copyright (c) 2002-2012, the original author or authors.
   3  *
   4  * This software is distributable under the BSD license. See the terms of the
   5  * BSD license in the documentation provided with this software.
   6  *
   7  * http://www.opensource.org/licenses/bsd-license.php
   8  */
   9 package jline.internal;
  10 
  11 import java.util.ArrayList;
  12 import java.util.List;
  13 
  14 import static jline.internal.Preconditions.checkNotNull;
  15 
  16 /**
  17  * Manages the JLine shutdown-hook thread and tasks to execute on shutdown.
  18  *
  19  * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
  20  * @since 2.7
  21  */
  22 public class ShutdownHooks
  23 {
  24     public static final String JLINE_SHUTDOWNHOOK = "jline.shutdownhook";
  25 
  26     private static final boolean enabled = Configuration.getBoolean(JLINE_SHUTDOWNHOOK, true);
  27 
  28     private static final List<Task> tasks = new ArrayList<Task>();
  29 
  30     private static Thread hook;
  31 
  32     public static synchronized <T extends Task> T add(final T task) {
  33         checkNotNull(task);
  34 


   1 /*
   2  * Copyright (c) 2002-2012, the original author or authors.
   3  *
   4  * This software is distributable under the BSD license. See the terms of the
   5  * BSD license in the documentation provided with this software.
   6  *
   7  * http://www.opensource.org/licenses/bsd-license.php
   8  */
   9 package jdk.internal.jline.internal;
  10 
  11 import java.util.ArrayList;
  12 import java.util.List;
  13 
  14 import static jdk.internal.jline.internal.Preconditions.checkNotNull;
  15 
  16 /**
  17  * Manages the JLine shutdown-hook thread and tasks to execute on shutdown.
  18  *
  19  * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
  20  * @since 2.7
  21  */
  22 public class ShutdownHooks
  23 {
  24     public static final String JLINE_SHUTDOWNHOOK = "jline.shutdownhook";
  25 
  26     private static final boolean enabled = Configuration.getBoolean(JLINE_SHUTDOWNHOOK, true);
  27 
  28     private static final List<Task> tasks = new ArrayList<Task>();
  29 
  30     private static Thread hook;
  31 
  32     public static synchronized <T extends Task> T add(final T task) {
  33         checkNotNull(task);
  34 


< prev index next >