void dgAsyncThread::Execute (dgInt32 threadID)
{
	dgAssert (threadID == m_id);
	while (!m_terminate) {
		SuspendExecution(m_myMutex);
		m_callerMutex.Release();
		if (!m_terminate) {
			TickCallback(threadID);
		}
	}
}
void dgMutexThread::Execute (dgInt32 threadID)
{
	// suspend this tread until the call thread decide to 
	dgAssert (threadID == m_id);
	while (!m_terminate) {
		// wait for the main thread to signal an update
		m_mutex.Wait();
		if (!m_terminate) {
			TickCallback(threadID);
		}
		m_parentMutex.Release();
	}
}
void dgAsyncThread::Execute(dgInt32 threadID)
{
	dgAssert(threadID == m_id);
	while (!m_terminate) {
		m_mutex.Wait();
		if (!m_terminate) {
			dgInterlockedExchange(&m_inUpdate, 1);
			dgInterlockedExchange(&m_beginUpdate, 1);
			TickCallback(threadID);
			dgInterlockedExchange(&m_inUpdate, 0);
		}
	}
}
void dgMutexThread::Execute (dgInt32 threadID)
{
	// suspend this tread until the call thread decide to 
	dgAssert (threadID == m_id);
	while (!m_terminate) {
		// wait for the main thread to signal an update
		SuspendExecution(m_myMutex);
		if (!m_terminate) {
			dgInterlockedExchange(&m_isBusy, 1);
			TickCallback(threadID);
			// let main thread resume execution
			m_callerMutex.Release();
			dgInterlockedExchange(&m_isBusy, 0);
		}
	}
	dgInterlockedExchange(&m_isBusy, 0);
}