[Insight-developers] problems multithreading with WIN32

Joshua Cates cates at sci . utah . edu
Mon, 28 Jul 2003 12:07:06 -0600 (MDT)


Hi,

ITK multithreading fails with > 4 threads on my (single processor) Windows
NT machine with the Borland compiler.  Can anyone duplicate this error?  
Anyone seen it before?


In itkMultiThreader.cxx line 287

  WaitForSingleObject(process_id[thread_loop], INFINITE);

never returns when thread_loop == 4 and m_NumberOfThreads == 5.


For example, try the following code:

ITK_THREAD_RETURN_TYPE MultiThreadTest( void *ptr )
{
  int threadID = ( (itk::MultiThreader::ThreadInfoStruct *)(ptr) )->ThreadID;

  std::cout << "test threadID = " << threadID << std::endl;
  return ITK_THREAD_RETURN_VALUE;
}


int main(int, char **)
{
  try
    {  
    itk::MultiThreader::Pointer multithreader = itk::MultiThreader::New();
    multithreader->SetNumberOfThreads(5);
    multithreader->SetSingleMethod( MultiThreadTest, 0);
    multithreader->SingleMethodExecute();
    }
  catch (itk::ExceptionObject &e)
    {
    std::cerr << e << std::endl;
    return 1;
    }
  return 0;
}


Josh.
______________________________
 Josh Cates			
 School of Computer Science	
 University of Utah
 Email: cates at sci . utah . edu
 Phone: (801) 587-7697
 URL:   http://www . sci . utah . edu/~cates