v12/src/PerfHarness/src/com/ibm/uk/hursley/perfharness/ControlThread.java
/**
	 * Handles shutdown sequence of WorkerThreads.  The current implementation notfies each thread
	 * of the shutdown status then interrupts it.  It waits for (default) 2 minutes for these threads
	 * before exiting anyway.
	 */
Handles shutdown sequence of WorkerThreads.  The current implementation notfies each thread
of the shutdown status then interrupts it.  It waits for (default) 2 minutes for these threads
before exiting anyway.
Handles shutdown sequence of WorkerThreads . The current implementation notfies each thread of the shutdown status then interrupts it . It waits for ( default ) 2 minutes for these threads before exiting anyway .
protected void doShutdown() {
		shutdown = true;
		if ( shutdownHookThread!=null && !shutdownHookThread.isAlive() ) {
			try {
				Runtime.getRuntime().removeShutdownHook(shutdownHookThread);
			} catch ( IllegalStateException e ) {
			}
		}
		stopWorkers( workers );
		if (stats!=null) {
			stats.stop();
		}
		if ( runlengthTimer!=null ) {
			runlengthTimer.cancel();
		}
		int count = Config.parms.getInt( "wk" );
		StringBuffer activethreads = new StringBuffer();
		waiting : while ((count-- != 0)) {
			activethreads.setLength(0);
			final Iterator<WorkerThread> iter = workers.iterator();
			while (iter.hasNext()) {
				final WorkerThread worker = iter.next();
				if ( (worker.getStatus()&WorkerThread.sENDED)==0 ) {
					activethreads.append(worker.getName());
					activethreads.append(" ");
					if ( (worker.getStatus()&WorkerThread.sENDING)==0 && count==5 ) {
						if (!worker.usesAsynchronousShutdownSignal()) {
							Log.logger.log(Level.FINER,
									"Interrupting inactive WorkerThread {0}",
									worker.getName());
							worker.interrupt();
						}
					}
				}
			}
			if (activethreads.length() > 0) {
				if (count % 10 == 0) {
					Log.logger.log(Level.WARNING, "Waiting for ( {0} )",
							activethreads);
				}
			} else {
				break waiting;
			}
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
			}
		} 
		removeController( this );
	}
protected void doShutdown ( ) { shutdown = true ; if ( shutdownHookThread != null && ! shutdownHookThread . isAlive ( ) ) { try { Runtime . getRuntime ( ) . removeShutdownHook ( shutdownHookThread ) ; } catch ( IllegalStateException e ) { } } stopWorkers ( workers ) ; if ( stats != null ) { stats . stop ( ) ; } if ( runlengthTimer != null ) { runlengthTimer . cancel ( ) ; } int count = Config . parms . getInt ( "wk" ) ; StringBuffer activethreads = new StringBuffer ( ) ; waiting : while ( ( count -- != 0 ) ) { activethreads . setLength ( 0 ) ; final Iterator < WorkerThread > iter = workers . iterator ( ) ; while ( iter . hasNext ( ) ) { final WorkerThread worker = iter . next ( ) ; if ( ( worker . getStatus ( ) & WorkerThread . sENDED ) == 0 ) { activethreads . append ( worker . getName ( ) ) ; activethreads . append ( " " ) ; if ( ( worker . getStatus ( ) & WorkerThread . sENDING ) == 0 && count == 5 ) { if ( ! worker . usesAsynchronousShutdownSignal ( ) ) { Log . logger . log ( Level . FINER , "Interrupting inactive WorkerThread {0}" , worker . getName ( ) ) ; worker . interrupt ( ) ; } } } } if ( activethreads . length ( ) > 0 ) { if ( count % 10 == 0 ) { Log . logger . log ( Level . WARNING , "Waiting for ( {0} )" , activethreads ) ; } } else { break waiting ; } try { Thread . sleep ( 1000 ) ; } catch ( InterruptedException e ) { } } removeController ( this ) ; }
Handles shutdown sequence of WorkerThreads.
Handles shutdown sequence of WorkerThreads .
// may be redundant in many circumstance, but not all. // remove shutdownHook if not already invoked // No-op // ... then wait for them for 2 minutes // if the worker is not even "ending" yet it must be stuck in the main code // so we will get it a shock. //no op // end while counting down