Hi robertosfield and hybr, Thanks a lot for the nice help.
My develop environment is windows XP 32 bit with SP3. On 32 bit machines the code works well. When I run on Win - 7 Ultimate 64 bit then I am getting run time error some times. I dont have development environment on 64 bit machine. I don't know how to provide stack trace on this testing machine. I modified my code such that the thread has only reading statement. I want to run all threads simultaneously (so reading will be fast). I dont want sysnc of threads. Here is my modified code. Code: //Globles struct ModelObj { int id; }; ModelObj obj[NUM_OF_MODELS]; Model model;//OBJ OF MODEL HANDLING CLASS HANDLE T[NUM_OF_MODELS]; CWinThread *pThread[NUM_OF_MODELS]; UINT ThreadProc1(LPVOID lpvoid) { ModelObj *temp = (ModelObj*)lpvoid; //model.mtForMarker[temp->id] = new osg::MatrixTransform; //model.modelSwitch->addChild(model.mtForMarker[temp->id].get()); model.modelForMarker[temp->id] = osgDB::readNodeFile(model.fileNames[temp->id]); if(model.modelForMarker[temp->id]) { model.mtForMarker[temp->id]->addChild(model.modelForMarker[temp->id].get()); //model.mtForMarker[temp->id]->addChild(model.sound_root.get()); // model.mtForMarker[temp->id]->setUpdateCallback( model.soundCB.get() ); } return 0; } In main Code: Code: ......... for(int i=0;i<NUM_OF_MODELS;i++) { obj[i].id=i; } strcpy(model.fileNames[0],"osg_01.osg"); strcpy(model.fileNames[1],"osg_02.OSG"); strcpy(model.fileNames[2],"osg_03.OSG"); DWORD ThreadId[NUM_OF_MODELS]; for(int i=0;i<NUM_OF_MODELS;i++) { model.mtForMarker[i] = new osg::MatrixTransform; model.modelSwitch->addChild(model.mtForMarker[i].get()); model.mtForMarker[i]->addChild(model.sound_root.get()); model.mtForMarker[i]->setUpdateCallback( model.soundCB.get() ); //pThread[i]=new CWinThread; std::cout<<"Thread: "<<i<<std::endl; pThread[i] = AfxBeginThread (ThreadProc1, (LPVOID)&obj[i]); pThread[i]->m_bAutoDelete=FALSE; } for (int j = 0; j < NUM_OF_MODELS; j ++) { T[j] = pThread[j]->m_hThread; } ::WaitForMultipleObjects(NUM_OF_MODELS, T, TRUE, INFINITE); for (int j = 0; j < NUM_OF_MODELS; j ++) { delete pThread[j]; } Once I tried to use binary formats. But when compared to OSG files its size is huge. So I stopped. I will try once again. (I am changing textures dynamically. Is it possible with binary formats?) Can you please guide me how to solve this problem? ... Thank you! Cheers, Koduri ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50181#50181 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org