v12/src/PerfHarness/src/com/ibm/uk/hursley/perfharness/ControlThread.java
/**
	 * Starts any WorkerThreads in the workers array which are not yet started.  It does this in a 
	 * controlled sequential manner, waiting for each thread's status to change to RUNNING before
	 * starting the next one.
	 * @param newWorkers If not null the given workers are started and are added to the main list of workers. 
	 * @return boolean True if all workers were started without error.
	 */
Starts any WorkerThreads in the workers array which are not yet started.  It does this in a
controlled sequential manner, waiting for each thread's status to change to RUNNING before
starting the next one.
@param newWorkers If not null the given workers are started and are added to the main list of workers.
@return boolean True if all workers were started without error.
Starts any WorkerThreads in the workers array which are not yet started . It does this in a controlled sequential manner waiting for each thread ' s status to change to RUNNING before starting the next one . @param newWorkers If not null the given workers are started and are added to the main list of workers . @return boolean True if all workers were started without error .
protected final boolean startWorkers( Collection<WorkerThread> newWorkers ) throws Exception {
		if (true == Config.parms.getBoolean("wp", false)) {
			return startWorkers(newWorkers, true);
		}
		final int workerInc = Config.parms.getInt( "wi" );
		final int waitPeriod = Config.parms.getInt( "wt" ) * 1000;
		int status = 0;
		if ( newWorkers!=null ) {
			addWorkers( newWorkers );
		}
		final Iterator<WorkerThread> iter = workers.iterator();
		Itera: while ( !shutdown && iter.hasNext() ) {
			final WorkerThread worker = iter.next();
			if ( (worker.getStatus() & WorkerThread.sCREATED)==0 ) {
				continue Itera;
			}
			worker.start();
			if ( waitPeriod>0 ) {
				long started = System.currentTimeMillis();				
				while ( System.currentTimeMillis()-started < waitPeriod) {
					if ( shutdown ) {
						return false;
					}
					status = worker.getStatus();
					if ((status & WorkerThread.sERROR) != 0) {
						Log.logger.log(Level.SEVERE,
								"Error starting WorkerThread {0}", worker
										.getName());
						return false;
					}
					if ( (status&WorkerThread.sCREATED)==0) {
						if ((status & WorkerThread.sRUNNING) != 0) {
							runningWorkers++;
							if ( iter.hasNext() ) {
								try {
									Thread.sleep(workerInc);
								} catch (InterruptedException e) {
								}
							} 
							continue Itera;
						} else if ( (status&(WorkerThread.sENDING|WorkerThread.sENDED)) !=0 ) {
						 	continue Itera;
						}
					} 
					try {
						Thread.sleep(200);
					} catch (InterruptedException e) {
					}
				} 
				Log.logger
						.log(
								Level.SEVERE,
								"WorkerThread start interval (-wt={0}) exceeded with no response from {1}",
								new Object[]{waitPeriod / 1000,
										worker.getName()});
				return false;				
			}  waitime>0
		} 
		return true;
	}
protected final boolean startWorkers ( Collection < WorkerThread > newWorkers ) throws Exception { if ( true == Config . parms . getBoolean ( "wp" , false ) ) { return startWorkers ( newWorkers , true ) ; } final int workerInc = Config . parms . getInt ( "wi" ) ; final int waitPeriod = Config . parms . getInt ( "wt" ) * 1000 ; int status = 0 ; if ( newWorkers != null ) { addWorkers ( newWorkers ) ; } final Iterator < WorkerThread > iter = workers . iterator ( ) ; Itera : while ( ! shutdown && iter . hasNext ( ) ) { final WorkerThread worker = iter . next ( ) ; if ( ( worker . getStatus ( ) & WorkerThread . sCREATED ) == 0 ) { continue Itera ; } worker . start ( ) ; if ( waitPeriod > 0 ) { long started = System . currentTimeMillis ( ) ; while ( System . currentTimeMillis ( ) - started < waitPeriod ) { if ( shutdown ) { return false ; } status = worker . getStatus ( ) ; if ( ( status & WorkerThread . sERROR ) != 0 ) { Log . logger . log ( Level . SEVERE , "Error starting WorkerThread {0}" , worker . getName ( ) ) ; return false ; } if ( ( status & WorkerThread . sCREATED ) == 0 ) { if ( ( status & WorkerThread . sRUNNING ) != 0 ) { runningWorkers ++ ; if ( iter . hasNext ( ) ) { try { Thread . sleep ( workerInc ) ; } catch ( InterruptedException e ) { } } continue Itera ; } else if ( ( status & ( WorkerThread . sENDING | WorkerThread . sENDED ) ) != 0 ) { continue Itera ; } } try { Thread . sleep ( 200 ) ; } catch ( InterruptedException e ) { } } Log . logger . log ( Level . SEVERE , "WorkerThread start interval (-wt={0}) exceeded with no response from {1}" , new Object [ ] { waitPeriod / 1000 , worker . getName ( ) } ) ; return false ; } } return true ; }
Starts any WorkerThreads in the workers array which are not yet started.
Starts any WorkerThreads in the workers array which are not yet started .
// do we use the new startup pooling option? // Skip any already running threads // poll thread for -wt seconds // start waiting for the thread to signal it is running				 // It failed ... // if it's up and running .... check next one // Note, sCONNECTING is ignored (we wait until it is running) // if not the last thread then sleep for wi millis //no op // end if // Note: WorkerThread has started and finished already ! maybe we should // report this as an error // end if // Polling sleep //no op // end while waiting for this thread to start // Note: thread may start later and threads=n output will not be updated				 // end if waitime>0 // Endfor server iteration