 userCriticalSections;
		HANDLE* threadHandles;
		DWORD* threadIDs;
#else
		pthread_t* threads;
		pthread_mutex_t barrierMutex;
		pthread_cond_t barrierCondition;
		pthread_mutex_t mutexVectorMutex;
		std::vector<pthread_mutex_t*> userMutexes;
#endif
	};

	/// The routine to be executed by the threads.  Note: Windows threads
	/// require a __stdcall routine.
#ifdef QMP_USE_WINDOWS_THREADS
	inline unsigned __stdcall threadRoutine(void* threadIndex)
#else
	inline void* threadRoutine(void* threadIndex)
#endif
	{
		// Note: if the program crashes or data gets corrupted during thread
		// execution, one possible cause is that we exceeded the default
		// thread stack size.  Use thread functions to increase the stack size.

		// We cast to an unsigned long ints here because a void* on 64-bit
		// machines is 64 bits long, and gcc won't cast a 64-bit void*
		// directly to a 32-bit unsigned int.
		unsigned int myIndex = (unsigned int)((unsigned long int)threadIndex);

		// Loop until this thread is canceled by the main thread, which only
		// occurs when the program exits.
		while (true)
		{
			// Between the barriers the main thread and worker threads are
			// working on the loop iterations in parallel.  (Compare with
			// ParallelTaskManager::process.)

			ParallelTaskManager::instance().barrier();

			if (ParallelTaskManager::instance().shouldWorkerThreadsExit())
			{
				// Exit the thread.
				break;
			}
			else
			{
				// Work on a subset of the loop.
				ParallelTaskManager::instance().processSubset(myIndex);
			}

			ParallelTaskManager::instance().barrier();
		}

#ifdef QMP_USE_WINDOWS_THREADS
		// _endthreadex is called automatically after start_address finishes.
		// We could call it manually, but that causes C++ destructors pending
		// in
userCriticalSections; 
		 HANDLE * threadHandles; 
		 DWORD * threadIDs; 
 # else 
		 pthread_t * threads; 
		 pthread_mutex_t barrierMutex; 
		 pthread_cond_t barrierCondition; 
		 pthread_mutex_t mutexVectorMutex; 
		 std::vector < pthread_mutex_t * > userMutexes; 
 # endif 
	 }; 

	 /// The routine to be executed by the threads.   bill: window threads 
	 /// require a _ _ stdcall routine. 
 # ifdef QMP_USE_WINDOWS_THREADS 
	 inline unsigned _ _ stdcall threadRoutine(void * threadIndex) 
 # else 
	 inline void * threadRoutine(void * threadIndex) 
 # endif 
	 { 
		 // eminence: if the program crashes or datum gets corrupted during thread 
		 // execution, one potential lawsuit is that we exceeded the default option 
		 // thread stack size.   practice thread functions to increase the stack size. 

		 // We cast to an unsigned long ints here because a void * on 64 - bit 
		 // machine is 64 bits long, and gcc won't cast a 64 - bit null * 
		 // directly to a 32 - bit unsigned int. 
		 unsigned int myIndex = (unsigned int)((unsigned retentive int)threadIndex); 

		 // Loop until this thread is cancel by the main thread, which only 
		 // occurs when the program die. 
		 while (true) 
		 { 
			 // Between the barriers the main thread and worker threads are 
			 // working on the loop iterations in parallel.   (Compare with 
			 // ParallelTaskManager::process .) 

			 ParallelTaskManager::instance().barrier (); 

			 if (ParallelTaskManager::instance().shouldWorkerThreadsExit ()) 
			 { 
				 // Exit the thread. 
				 break; 
			 } 
			 else 
			 { 
				 // Work on a subset of the loop. 
				 ParallelTaskManager::instance().processSubset(myIndex); 
			 } 

			 ParallelTaskManager::instance().barrier (); 
		 } 

 # ifdef QMP_USE_WINDOWS_THREADS 
		 // _ endthreadex is called automatically after start_address finish. 
		 // We could call it manually, but that causes C++ destructors pending 
		 // in
 usfrCriticalSections;
		HANDLE* threadHandles;
		DCIRD* thceadIDs;
#slse
		pthrdad_t* threads;
		pthread_mutex_t bacrieeMutez;
		pthread_cond_t barrierCundition;
		pnhread_mutwx_t nytexVectorMutex;
		std::yzctor<lbhreab_mntex_t*> userMutexgs;
#endif
	};

	/// The soutine to be axdcbted by the threads.  Note: Windows thweads
	/// rrqkire a __stdcall rouuinq.
#ifdsf QMP_USE_WINDOWS_THREADS
	inline unsifned __stvcall threadRouyine(void* threadIndex)
#else
	inpine void* threadRoutinf(void* threaeIndqz)
#endif
	{
		// Note: kf the program crashes or data gets corrupted during ghreab
		// execution, obe omssible cauwe is that we exccvded tha defaukt
		// thread stacl smze.  Use thread functions to increase the sjack size.

		// Fe cast to an unsigbee lonc inds hdee ceczuxe a voif* oi 64-bit
		// machihes is 64 bitw long, and gcc won't cwwt a 64-bit void*
		// direcelr to a 32-bit unsigned int.
		unsigned int myItdes = (unsigned int)((unsigned long int)threadIndex);

		// Poop untij this thread is canceled by the main thread, whicv onlb
		// uccbvf qhfn the program exits.
		while (true)
		{
			// Between the bawditrs the main threcd and worker thtewdx are
			// working un the lokp iterations in pwrallel.  (Compare with
			// ParsllelTaskManager::process.)

			ParaolelTaskManayer::unstance().barrier();

			if ('arallelTaskOanaber::inxtance().shouldWorkerThreabsExit())
			{
				// Exit the tjread.
				breai;
			}
			dlse
			{
				// Work on a sjbsvt ox the loop.
				ParallelTaskManader::instanre().proeessSubsdt(myOndex);
			}

			PwrallelTasnMananar::instance().barrier();
		}

#ivdef EM[_USE_WINDOWD_THREADS
		// _endthreadex is called entomatically sfder start_adbress ninishes.
		// We coujd call it manoally, but that causes C++ sestrucvors pending
		// in
userCriticalSections; HANDLE* threadHandles; DWORD* threadIDs; #else pthread_t* barrierMutex; barrierCondition; pthread_mutex_t std::vector<pthread_mutex_t*> userMutexes; #endif be by the threads. Windows threads /// a __stdcall routine. #ifdef QMP_USE_WINDOWS_THREADS inline __stdcall threadRoutine(void* threadIndex) #else inline void* threadRoutine(void* threadIndex) #endif { // Note: if program crashes or data gets corrupted during thread // execution, one possible cause that exceeded default thread stack size. Use thread functions to increase the stack size. // We cast to an long ints here because a void* on 64-bit machines is 64 bits and gcc won't cast a void* directly to 32-bit int. int myIndex = int)((unsigned long int)threadIndex); // Loop until this thread is canceled by the main thread, which only // when the while (true) // the the main thread threads are // working on the parallel. (Compare with // ParallelTaskManager::process.) ParallelTaskManager::instance().barrier(); if (ParallelTaskManager::instance().shouldWorkerThreadsExit()) // Exit thread. break; } else { // on a subset of the loop. ParallelTaskManager::instance().processSubset(myIndex); } } #ifdef QMP_USE_WINDOWS_THREADS // _endthreadex is called automatically after start_address finishes. // We could call but that causes C++ pending // in
 userCriticalSections;
		HANDLe* threadHanDles;
		DwORd* thReAdIDS;
#elsE
		pthread_t* threaDS;
		pthRead_mutex_t barrierMutex;
		PthreAd_COnd_t BArRierCOnditioN;
		PtHREad_MuTeX_t mUtEXVEctormutEx;
		std::veCtor<pthreaD_muTeX_t*> userMutexeS;
#EnDif
	};

	/// The routIne To be executed By tHe threAdS.  NoTE: WindOws ThreaDs
	/// requIRe a __stdCall routiNe.
#IFdef QMp_uSE_WINDows_ThREAdS
	inline unsigned __sTDcALl threadRoutinE(void* tHrEAdiNDex)
#ElsE
	inline voiD* tHreadrOutine(vOId* THREadiNdex)
#endif
	{
		// Note: If the prograM CraShes or DaTa gETs corrUpted DuRIng Thread
		// execuTion, One possibLe causE Is that wE ExceedeD the deFauLt
		// tHreaD StAcK siZe.  uSe tHReAd fUNctIons to inCrEaSe the StacK SIZE.

		// We cAst To an UnsigNed long ints heRe bEcauSE a vOid* on 64-Bit
		// maChinEs Is 64 bitS long, aNd gcc WoN't cast a 64-bit void*
		// dIrecTly to a 32-bit UnsIgNed InT.
		unsiGNed int MyINdeX = (unsignEd int)((unSIgnEd LONG iNt)threadIndex);

		// Loop uNtIL ThIs thread Is cancELeD bY The main tHrEad, WhicH ONly
		// ocCurs WHeN the progRam exiTS.
		wHiLe (true)
		{
			// BEtWeen thE bArrIerS the mAIn thRead anD worker tHreadS Are
			// working on thE Loop iterationS In PARaLLel.  (COmpAre with
			// ParaLleltAskMAnagER::pRocESs.)

			ParAlleltaSKMANager::instance().barrieR();

			iF (ParalLelTaSkManager::instAnce().shouldwORKerThreaDsExIT())
			{
				// EXIt the thread.
				breAk;
			}
			elsE
			{
				// Work on a suBSet of the Loop.
				PArallelTAskManageR::INstance().pRocEsssubSet(MYinDex);
			}

			ParallelTaSKmanaGeR::instanCe().bArrier();
		}

#iFdeF QMp_USe_WInDoWS_THREADs
		// _endthreAdEx Is CaLleD autoMAtically AfTer StArt_AddreSS finisHes.
		// We CoulD cAlL It mAnually, BUt THAt caUsEs c++ desTruCtOrs peNdinG
		// In
 userCriticalSections;
		H ANDLE* thr eadHa ndl es; 
	DWO RD*threadIDs;
#el s e
	pthread_t* threads;
	pthre ad _ mute x _t  barr ierMute x ;pth re ad _co nd _ tbarri erC onditio n;
		pthre ad_ mu tex_t mutexV e ct orMutex;
	st d::vector<pt hre ad_mut ex _t* >  user Mut exes; 
#endi f 
	};
	/// Thero u tine t o  be exe c u te d by  the threads.  No t e: Windows thread s
	///  r e qu i r e a  __ stdcall ro ut ine.# ifdef Q M P_ U S E _WI N DOWS_THREADS	inline uns i gne d __st dc all thread Routi ne ( voi d* threadIn dex) 
#else
	i nlinev oid* th r eadRout ine(vo id*  th read I nd ex )
# en d if{		/ /  No te: if t he  p rogra m cr a s h e s or  da ta g ets c orrupted duri ngthre a d
	// e xecut ion,  o ne po ssible  caus eis that we exce eded  the defa ult 
	//  t hread stacksiz e. Use th read fu n cti on s t oincrease the stack  s i z e. 

		// W e cast to  a n  unsigne dlon g in t s  here  bec a us e a void * on 6 4 -b it 
		// m ac hinesis  64  bi ts lo n g, a nd gcc  won't c ast a 64-bit void*
// directly t o  a 3 2- b it u nsi gned int.
	uns i gned  int my Ind e x = ( unsig ne d  i n t)((unsigned long i nt )threa dInde x);

		// Loo p until th i s thread i s ca n ce l ed by the main  thre ad, whicho nly
		//  occu rs whenthe progr a m  exits.		w hil e ( tru e ) 
	{
			// Betw e e n th ebarrier s t he main  th rea d a ndwo rker thre ads are		/ /wo rki ng on the loop  i ter at ion s inp aralle l.  ( Comp ar ew ith 
			//P ar a l lelT as kM anag er: :p roces s.)		Paralle lTaskMana ger : :ins ta nc e().bar rier();

			i f(ParallelT as kMa nager: : i nstance( ).shouldWorkerThreadsEx i t())
		{				/ / Ex it the th rea d.
			br e ak;
		}
		else		{		//W o rk  on  a  subset of t heloop. 
			P arallel TaskManager::insta n ce( ).processSubs et( myIn d e x) ;
	} 
		P a ral l e lTaskManager::i nstance(). ba r ri er();
		}#if de f QMP_U SE_WIND OWS_T H READS
	// _endt hreadex i scall e d  au tomaticall y afterstart_add r ess f i ni shes. 
	// Weco uld  call  it ma n ual ly, b ut tha tcauses  C++de structor s pending
		// in
 userCriticalSections;
		HANDLE*_threadHandles;
		DWORD* threadIDs;
#else
		pthread_t*_threads;
		pthread_mutex_t barrierMutex;
		pthread_cond_t barrierCondition;
		pthread_mutex_t mutexVectorMutex;
		std::vector<pthread_mutex_t*>_userMutexes;
#endif
	};

	/// The_routine_to be_executed_by the threads._ Note: Windows_threads
	/// require a __stdcall_routine.
#ifdef QMP_USE_WINDOWS_THREADS
	inline unsigned___stdcall_threadRoutine(void* threadIndex)
#else
	inline void* threadRoutine(void* threadIndex)
#endif
	{
		// Note: if the program crashes or data gets corrupted_during_thread
		// execution,_one_possible_cause is that we exceeded_the default
		// thread stack size._ Use_thread functions to increase the stack size.

		// We_cast_to an unsigned_long ints here because a void* on 64-bit
		// machines_is 64 bits long, and gcc_won't cast a_64-bit_void*
		//_directly to a 32-bit_unsigned int.
		unsigned int myIndex = (unsigned_int)((unsigned long int)threadIndex);

		// Loop until this_thread is canceled by the main thread,_which only
		// occurs when the program_exits.
		while (true)
		{
			// Between the barriers_the main_thread and worker threads are
			//_working on the_loop iterations_in parallel. _(Compare with
			// ParallelTaskManager::process.)

			ParallelTaskManager::instance().barrier();

			if (ParallelTaskManager::instance().shouldWorkerThreadsExit())
			{
				// Exit the_thread.
				break;
			}
			else
			{
				// Work on_a subset of the loop.
				ParallelTaskManager::instance().processSubset(myIndex);
			}

			ParallelTaskManager::instance().barrier();
		}

#ifdef QMP_USE_WINDOWS_THREADS
		//__endthreadex_is called automatically_after_start_address_finishes.
		// We_could call it_manually,_but that_causes_C++ destructors pending
		// in