List of usage examples for java.lang Object wait
public final void wait() throws InterruptedException
From source file:org.echocat.jconscius.cluster.impl.relay.station.RelayStationLauncher.java
public static void main(String[] arguments) throws Exception { final RelayStation station = createStation(arguments); if (station != null) { final Object lock = new Object(); final Thread shutdownThread = new Thread("ShutdownHook") { @Override/* w w w. j a v a 2 s .co m*/ public void run() { LOG.info("Station is going down now..."); station.close(); LOG.info("Station is down! Bye."); synchronized (lock) { lock.notifyAll(); } } }; Runtime.getRuntime().addShutdownHook(shutdownThread); LOG.info("Station is starting..."); station.init(); LOG.info("Station is ready!"); //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized (lock) { lock.wait(); } } }
From source file:eu.stratosphere.nephele.taskmanager.TaskManager.java
/** * Entry point for the program./*from w ww .jav a 2 s.c om*/ * * @param args * arguments from the command line * @throws IOException */ @SuppressWarnings("static-access") public static void main(String[] args) throws IOException { Option configDirOpt = OptionBuilder.withArgName("config directory").hasArg() .withDescription("Specify configuration directory.").create("configDir"); // tempDir option is used by the YARN client. Option tempDir = OptionBuilder.withArgName("temporary directory (overwrites configured option)").hasArg() .withDescription("Specify temporary directory.").create(ARG_CONF_DIR); configDirOpt.setRequired(true); tempDir.setRequired(false); Options options = new Options(); options.addOption(configDirOpt); options.addOption(tempDir); CommandLineParser parser = new GnuParser(); CommandLine line = null; try { line = parser.parse(options, args); } catch (ParseException e) { System.err.println("CLI Parsing failed. Reason: " + e.getMessage()); System.exit(FAILURE_RETURN_CODE); } String configDir = line.getOptionValue(configDirOpt.getOpt(), null); String tempDirVal = line.getOptionValue(tempDir.getOpt(), null); // First, try to load global configuration GlobalConfiguration.loadConfiguration(configDir); if (tempDirVal != null // the YARN TM runner has set a value for the temp dir // the configuration does not contain a temp direcory && GlobalConfiguration.getString(ConfigConstants.TASK_MANAGER_TMP_DIR_KEY, null) == null) { Configuration c = GlobalConfiguration.getConfiguration(); c.setString(ConfigConstants.TASK_MANAGER_TMP_DIR_KEY, tempDirVal); LOG.info("Setting temporary directory to " + tempDirVal); GlobalConfiguration.includeConfiguration(c); } System.err.println("Configuration " + GlobalConfiguration.getConfiguration()); LOG.info("Current user " + UserGroupInformation.getCurrentUser().getShortUserName()); { // log the available JVM memory long maxMemoryMiBytes = Runtime.getRuntime().maxMemory() >>> 20; LOG.info("Starting TaskManager in a JVM with " + maxMemoryMiBytes + " MiBytes maximum heap size."); } // Create a new task manager object try { new TaskManager(); } catch (Exception e) { LOG.fatal("Taskmanager startup failed: " + e.getMessage(), e); System.exit(FAILURE_RETURN_CODE); } // park the main thread to keep the JVM alive (all other threads may be daemon threads) Object mon = new Object(); synchronized (mon) { try { mon.wait(); } catch (InterruptedException ex) { } } }
From source file:eu.stratosphere.nephele.jobmanager.JobManager.java
/** * Entry point for the program/*from w ww .ja va 2s. c om*/ * * @param args * arguments from the command line */ public static void main(String[] args) { // determine if a valid log4j config exists and initialize a default logger if not if (System.getProperty("log4j.configuration") == null) { Logger root = Logger.getRootLogger(); root.removeAllAppenders(); PatternLayout layout = new PatternLayout("%d{HH:mm:ss,SSS} %-5p %-60c %x - %m%n"); ConsoleAppender appender = new ConsoleAppender(layout, "System.err"); root.addAppender(appender); root.setLevel(Level.INFO); } JobManager jobManager; try { jobManager = initialize(args); // Start info server for jobmanager jobManager.startInfoServer(); } catch (Exception e) { LOG.fatal(e.getMessage(), e); System.exit(FAILURE_RETURN_CODE); } // Clean up is triggered through a shutdown hook // freeze this thread to keep the JVM alive (the job manager threads are daemon threads) Object w = new Object(); synchronized (w) { try { w.wait(); } catch (InterruptedException e) { } } }
From source file:org.apache.flink.runtime.taskmanager.TaskManager.java
/** * Entry point for the TaskManager executable. * //www . j a v a2 s . co m * @param args Arguments from the command line * @throws IOException */ @SuppressWarnings("static-access") public static void main(String[] args) throws IOException { Option configDirOpt = OptionBuilder.withArgName("config directory").hasArg() .withDescription("Specify configuration directory.").create("configDir"); // tempDir option is used by the YARN client. Option tempDir = OptionBuilder.withArgName("temporary directory (overwrites configured option)").hasArg() .withDescription("Specify temporary directory.").create(ARG_CONF_DIR); configDirOpt.setRequired(true); tempDir.setRequired(false); Options options = new Options(); options.addOption(configDirOpt); options.addOption(tempDir); CommandLineParser parser = new GnuParser(); CommandLine line = null; try { line = parser.parse(options, args); } catch (ParseException e) { System.err.println("CLI Parsing failed. Reason: " + e.getMessage()); System.exit(STARTUP_FAILURE_RETURN_CODE); } String configDir = line.getOptionValue(configDirOpt.getOpt(), null); String tempDirVal = line.getOptionValue(tempDir.getOpt(), null); // First, try to load global configuration GlobalConfiguration.loadConfiguration(configDir); if (tempDirVal != null // the YARN TM runner has set a value for the temp dir // the configuration does not contain a temp directory && GlobalConfiguration.getString(ConfigConstants.TASK_MANAGER_TMP_DIR_KEY, null) == null) { Configuration c = GlobalConfiguration.getConfiguration(); c.setString(ConfigConstants.TASK_MANAGER_TMP_DIR_KEY, tempDirVal); LOG.info("Setting temporary directory to " + tempDirVal); GlobalConfiguration.includeConfiguration(c); } // print some startup environment info, like user, code revision, etc EnvironmentInformation.logEnvironmentInfo(LOG, "TaskManager"); // Create a new task manager object try { createTaskManager(ExecutionMode.CLUSTER); } catch (Throwable t) { LOG.error("Taskmanager startup failed: " + t.getMessage(), t); System.exit(STARTUP_FAILURE_RETURN_CODE); } // park the main thread to keep the JVM alive (all other threads may be daemon threads) Object mon = new Object(); synchronized (mon) { try { mon.wait(); } catch (InterruptedException ex) { } } }
From source file:Main.java
public static void wait(Object object) { try {//from w ww.ja v a 2 s . c o m object.wait(); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:Main.java
public static void waitNoShit(Object o) { try {//w ww . j a v a 2 s.c o m o.wait(); } catch (InterruptedException e) { } }
From source file:Main.java
public static void wait(Object o) { try {//from www.j ava2 s . co m o.wait(); } catch (InterruptedException e) { } }
From source file:Main.java
public static void waitWithoutInterrupt(Object object) { try {/*w ww.j a va 2 s . c o m*/ object.wait(); } catch (InterruptedException e) { Log.w(TAG, "unexpected interrupt: " + object); } }
From source file:Main.java
public static void wait(Object o) { try {/*from w w w . jav a 2 s . co m*/ synchronized (o) { o.wait(); } } catch (InterruptedException e) { // ignore } }
From source file:Main.java
/** * Waits for a object for synchronization purposes. *//*from w ww . j a v a 2s . co m*/ public static void wait(Object obj) { synchronized (obj) { try { obj.wait(); } catch (InterruptedException inex) { //ignore } } }