inmar 0 Newbie Poster

Hi

I'm using ACE_Thread_Manager to spawn a thread. But it is not spawning the thread. After including ACE_Process_Manager::instance()->open(); in the main then thread is spawned. The sample code is:

class DataType{
    public:
    DataType():data(0){}
    void increment(){ data++;}
    void set(int new_data){ data=new_data;}
    void decrement(){ data--;}
    int get(){return data;}
    private:
    int data;
};
ACE_TSS<DataType> data;
static void* thread1(void*)
{
    data->set(10);
    ACE_DEBUG((LM_DEBUG,"(%t)The value of data is %d \n",data->get()));
    for(int i=0;i<5;i++)
    data->increment();
    ACE_DEBUG((LM_DEBUG,"(%t)The value of data is %d \n",data->get()));
    return 0;
}
static void * thread2(void*)
{
    data->set(100);
    ACE_DEBUG((LM_DEBUG,"(%t)The value of data is %d \n",data->get()));
    for(int i=0; i<5;i++)
    data->increment();
    ACE_DEBUG((LM_DEBUG,"(%t)The value of data is %d \n",data->get()));
    return 0;
}
int main(int argc, char*argv[])
{
    [B]ACE_Process_Manager::instance()->open();[/B]
    //Spawn off the first thread
    //tmanager->instance()->open();
    tmanager->spawn((ACE_THR_FUNC)thread1,0,THR_NEW_LWP| THR_DETACHED);
    //Spawn off the second thread
    tmanager->spawn((ACE_THR_FUNC)thread2,0,THR_NEW_LWP| THR_DETACHED);
    tmanager->spawn((ACE_THR_FUNC)thread1,0,THR_NEW_LWP| THR_DETACHED);
    //Wait for all threads in the manager to complete.
    tmanager->wait();
    ACE_DEBUG((LM_DEBUG,"Both threads done.Exiting.. \n"));
    return 0;
}

Here for spawning a thread why ACE_Process_Manager instance is needed ?
Can anyone explain the reason ....?

Thanks
Inmar