v12/src/PerfHarness/src/com/ibm/uk/hursley/perfharness/ControlThread.java
/**
	 * Sets up timer and statistics threads then starts the required number of WorkerThreads and waits for them to end or for
	 * shutdown to be signalled.  ControlThread then tries to terminate remaining threads as nicely
	 * as possible.
	 */
Sets up timer and statistics threads then starts the required number of WorkerThreads and waits for them to end or for
shutdown to be signalled.  ControlThread then tries to terminate remaining threads as nicely
as possible.
Sets up timer and statistics threads then starts the required number of WorkerThreads and waits for them to end or for shutdown to be signalled . ControlThread then tries to terminate remaining threads as nicely as possible .
public void run() {
		boolean workerThreadsPresent = true;
		Config.markLoaded();
		if ( Log.errorsReported() ) {
			System.exit(1);
		}
		try {
			Log.logger.log( Level.INFO, "START");
			installShutdownMethods();
			int numworkers = Config.parms.getInt( "nt" );
			startStatsThread();
			startCmdThread();			
			if ( Config.parms.getString( "tc" ).indexOf("Nothing")>=0 ) {
				run_ThreadSizeLoop();
			} else {
				setNumWorkers(numworkers);
				if ( startWorkers(null) ) {
					startTimerThread();
					synchronized( this ) {
						while (!shutdown && (workerThreadGroup.activeCount() > 0) && workerThreadsPresent) {
							int count = workerThreadGroup.activeCount();
							int workerCount = 0;
							Log.logger.log(Level.FINE, "ActiveCount: " + count);
							if (count > 0) {
								Thread threads[] = new Thread[count];
								int rc = workerThreadGroup.enumerate(threads);
								for (int t = 0; t < rc; t++) {
									Log.logger.log(Level.FINEST, "ThreadName: " + threads[t].getName());
									if (threads[t].getName().startsWith(workerClass)) {
										workerCount++;
									}
								}
							}
							Log.logger.log(Level.FINE, "Worker Count: " + workerCount);
							workerThreadsPresent = (workerCount != 0);
							try {
								this.wait(5 * 1000);
							} catch (InterruptedException e) {
							}
						} 
					} 
				} 
			} 
		} catch (Exception e) {
			Log.logger.log( Level.SEVERE, "Fatal Error.", e );
		} finally {
			stats.setDefaultEndTime( System.currentTimeMillis() );
			stats.setStaticStartTime( staticStartTime );
			doShutdown();
			stats.printFinalSummary();
			Log.logger.log( Level.INFO, "STOP");
		}
	}
public void run ( ) { boolean workerThreadsPresent = true ; Config . markLoaded ( ) ; if ( Log . errorsReported ( ) ) { System . exit ( 1 ) ; } try { Log . logger . log ( Level . INFO , "START" ) ; installShutdownMethods ( ) ; int numworkers = Config . parms . getInt ( "nt" ) ; startStatsThread ( ) ; startCmdThread ( ) ; if ( Config . parms . getString ( "tc" ) . indexOf ( "Nothing" ) >= 0 ) { run_ThreadSizeLoop ( ) ; } else { setNumWorkers ( numworkers ) ; if ( startWorkers ( null ) ) { startTimerThread ( ) ; synchronized ( this ) { while ( ! shutdown && ( workerThreadGroup . activeCount ( ) > 0 ) && workerThreadsPresent ) { int count = workerThreadGroup . activeCount ( ) ; int workerCount = 0 ; Log . logger . log ( Level . FINE , "ActiveCount: " + count ) ; if ( count > 0 ) { Thread threads [ ] = new Thread [ count ] ; int rc = workerThreadGroup . enumerate ( threads ) ; for ( int t = 0 ; t < rc ; t ++ ) { Log . logger . log ( Level . FINEST , "ThreadName: " + threads [ t ] . getName ( ) ) ; if ( threads [ t ] . getName ( ) . startsWith ( workerClass ) ) { workerCount ++ ; } } } Log . logger . log ( Level . FINE , "Worker Count: " + workerCount ) ; workerThreadsPresent = ( workerCount != 0 ) ; try { this . wait ( 5 * 1000 ) ; } catch ( InterruptedException e ) { } } } } } } catch ( Exception e ) { Log . logger . log ( Level . SEVERE , "Fatal Error." , e ) ; } finally { stats . setDefaultEndTime ( System . currentTimeMillis ( ) ) ; stats . setStaticStartTime ( staticStartTime ) ; doShutdown ( ) ; stats . printFinalSummary ( ) ; Log . logger . log ( Level . INFO , "STOP" ) ; } }
Sets up timer and statistics threads then starts the required number of WorkerThreads and waits for them to end or for
 shutdown to be signalled.
Sets up timer and statistics threads then starts the required number of WorkerThreads and waits for them to end or for shutdown to be signalled .
// Flag to indicate that we have found threads that match our worker class // Inform config module to finalise syntax checking // Start (anonymous inner class) stats thread // Start command listener thread // Special, if we are running DoNothingThread then we // are measuring the memory usage per thread. // 3b. // Start threads sequentially // Sleep for remainder of testrun //Workers are already started, so shouldnt have to do any complicated retesting logic here //We are only looking for at least one thread that matches the required worker class							 // Swallowed //end while //end sync // end if startworkers // end if threadsizeloop // Handle a fatal error // Clear up code carefully in fair weather or foul. // Set rough approximation of endTime  // Kill all workers