All Downloads are FREE. Search and download functionalities are using the official Maven repository.

processing.app.exec.ProcessRegistry Maven / Gradle / Ivy

Go to download

Processing is a programming language, development environment, and online community. This PDE package contains the Processing IDE.

There is a newer version: 3.3.7
Show newest version
package processing.app.exec;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class ProcessRegistry {
  private static final Set REGISTRY = Collections
      .synchronizedSet(new HashSet());

  static {
    Runtime.getRuntime().addShutdownHook(new Thread() {
      @Override
      public void run() {
        synchronized (REGISTRY) {
          for (final Process p : REGISTRY) {
            try {
              //              System.err.println("Cleaning up rogue process " + p);
              p.destroy();
            } catch (final Exception drop) {
            }
          }
        }
      }
    });
  }

  /**
  * When starting up a process
  * @param p
  */
  public static void watch(final Process p) {
    REGISTRY.add(p);
  }

  public static void unwatch(final Process p) {
    REGISTRY.remove(p);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy