Wait for the process to finish during a certain amount of time, otherwise stops the process.

@param self           a Process
@param numberOfMillis the number of milliseconds to wait before stopping the process
@since 1.0
346895
public static void waitForOrKill(Process self, long numberOfMillis) {
        ProcessRunner runnable = new ProcessRunner(self);
        Thread thread = new Thread(runnable);
        thread.start();
        runnable.waitForOrKill(numberOfMillis);
    }
1226344
public synchronized boolean waitForFinish() throws Throwable {
    while (!done && exception == null) {
      wait();
    }
    if (exception != null) {
      throw exception;
    }
    return done;
  }
749852
public void stop(long millisec) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Stopping (" + millisec + ") : " + this);
        }
        if (0 == millisec) {
            setState(STATE_STOPPED);
        } else {
            setState(STATE_STOPPING);
        }
    }
549264
@Override
    public final synchronized void stopService(long millis) {
        running = false;
        try {
            if (keepRunning) {
                keepRunning = false;
                interrupt();
                quit();
                if (0L == millis) {
                    join();
                } else {
                    join(millis);
                }
            }
        } catch (InterruptedException e) {
            //its possible that the thread exits between the lines keepRunning=false and interrupt above
            log.warn("Got interrupted while stopping {}", this, e);

            Thread.currentThread().interrupt();
        }
    }
1039624
public static void sleep(long millis) {
		try {
			Thread.sleep(millis);
		}
		catch (InterruptedException ex) {
			Thread.currentThread().interrupt();
		}
	}
703761
@FFDCIgnore({ InterruptedException.class })
    public synchronized void waitForLevel() {
        // Don't bother waiting if the vm has been shutdown in the meanwhile...
        while (levelReached.get() == false && !shutdownHook.vmShutdown()) {
            try {
                // waiting for a start level event should not take long
                wait(1000);
            } catch (InterruptedException e) {
                /** No-op **/
            }
        }
    }
1340210
public static int waitForExitProcess(Pointer hProcess) throws InterruptedException {
        while (true) {
            if (Thread.interrupted())
                throw new InterruptedException();

            Kernel32.INSTANCE.WaitForSingleObject(hProcess,1000);
            IntByReference exitCode = new IntByReference();
            exitCode.setValue(-1);
            Kernel32.INSTANCE.GetExitCodeProcess(hProcess,exitCode);

            int v = exitCode.getValue();
            if (v !=Kernel32.STILL_ACTIVE) {
                return v;
            }
        }
    }
373012
public void waitWhileRunning(long ms) {

        int i = 0;
        // wait until it is done or time is over
        synchronized (this) {
            try {
                Thread.sleep(100); // wait a bit to give the publish engine the chance to actualize the state
            } catch (InterruptedException e) {
                // ignore
                e.printStackTrace();
            }
            while (isRunning() && ((MS_ONE_SECOND * i) <= ms)) {
                try {
                    Thread.sleep(MS_ONE_SECOND); // wait a second
                } catch (InterruptedException e) {
                    // ignore
                    e.printStackTrace();
                }
                i++;
            }
        }
    }
464604
static void exit(int status) {
        boolean runMoreFinalizers = false;
        synchronized (lock) {
            if (status != 0) runFinalizersOnExit = false;
            switch (state) {
            case RUNNING:       /* Initiate shutdown */
                state = HOOKS;
                break;
            case HOOKS:         /* Stall and halt */
                break;
            case FINALIZERS:
                if (status != 0) {
                    /* Halt immediately on nonzero status */
                    halt(status);
                } else {
                    /* Compatibility with old behavior:
                     * Run more finalizers and then halt
                     */
                    runMoreFinalizers = runFinalizersOnExit;
                }
                break;
            }
        }
        if (runMoreFinalizers) {
            runAllFinalizers();
            halt(status);
        }
        synchronized (Shutdown.class) {
            /* Synchronize on the class object, causing any other thread
             * that attempts to initiate shutdown to stall indefinitely
             */
            sequence();
            halt(status);
        }
    }
839895
public void waitForExit()
    {
        synchronized (m_frameworkProcess) {
            try
            {
                LOG.debug( "Waiting for framework exit." );
                System.out.println();
                m_frameworkProcess.waitFor();
                shutdown();
            }
            catch( Throwable e )
            {
                LOG.debug( "Early shutdown.", e );
                shutdown();
            }
        }
    }
138144
public void waitForExit() {
        if (shutdownHook != null) {
            synchronized (shutdownHookMonitor) {
                if (shutdownHook != null) {
                    synchronized (frameworkProcessMonitor) {
                        try {
                            frameworkProcess.waitFor();
                            shutdown();
                        // CHECKSTYLE:SKIP
                        } catch (Throwable e) {
                            shutdown();
                        }
                    }
                }
            }
        }
    }
333172
void waitRun(long waitMillis, int waitNanos, boolean cancelOnTimeOut) {
        if (!mDone) {
            synchronized (this) {
                if (!mDone) {
                    try {
                        this.wait(waitMillis, waitNanos);
                    } catch (InterruptedException ignored) {
                    } finally {
                        if (!mDone && cancelOnTimeOut)
                            mDone = true;
                    }
                }
            }
        }
    }
1154271
private void waitForCompletion() {
        for (ListenableFuture<?> future : pendingTasks.values()) {
            try {
                future.get();
            } catch (InterruptedException | ExecutionException e) {
                LOG.error("[" + this + "] Error waiting for writes to complete: " + e.getMessage());
            }
        }
    }
1251382
public void waitForPendingFutures() {
        // Wait inbox to become empty:
        Log.v(Log.TAG_BATCHER, "%s: waitForPendingFutures is called ...", this);

        while (true) {
            ScheduledFuture future;
            synchronized (mutex) {
                while (!inbox.isEmpty()) {
                    try {
                        Log.v(Log.TAG_BATCHER, "%s: waitForPendingFutures, inbox size: %d",
                                this, inbox.size());
                        mutex.wait(300);
                    } catch (InterruptedException e) {
                    }
                }
                future = pendingFuture;
            }

            // Wait till ongoing computation completes:
            if (future != null && !future.isDone() && !future.isCancelled()) {
                try {
                    future.get();
                } catch (Exception e) {
                    Log.e(Log.TAG_BATCHER, "%s: Error while waiting for pending futures", e, this);
                }
            }

            synchronized (mutex) {
                if (inbox.isEmpty())
                    break;
            }
        }

        Log.v(Log.TAG_BATCHER, "%s: waitForPendingFutures done", this);
    }
729128
private static void waiting(int milliseconds) {
        long t0, t1;
        t0 = System.currentTimeMillis();
        do {
            t1 = System.currentTimeMillis();
        } while ((t1 - t0) < milliseconds);
    }
1159295
public static boolean sleep(Number millis) {
		if (millis == null) {
			return true;
		}

		try {
			Thread.sleep(millis.longValue());
		} catch (InterruptedException e) {
			return false;
		}
		return true;
	}
607334
@Override
    public void waitForFinish() throws IOException
    {
        if (future == null)
        {
            throw new IllegalStateException("not started");
        }
        try
        {
            future.get();
        }
        catch (InterruptedException | ExecutionException ex)
        {
            throw new IOException(ex);
        }
    }