class Conncet
{public:
int creat (int name)
{
for(;;)
cout<<name<<endl;
return 0;
}
};
class HA_CommandHandler:public ACE_Task_Base
{
public:
int name;
HA_CommandHandler (int name)
{
name = name;
}
virtual int svc(void)
{
cout<<name<<endl;
Conncet c1;
c1.creat(name);
return 0;
}
};
int ACE_TMAIN(int,ACE_TCHAR *[])
{
int x=1,y=2,z=3,j=4;
HA_CommandHandler handler1(x);
HA_CommandHandler handler2(y);
HA_CommandHandler handler3(z);
HA_CommandHandler handler4(j);
int result1 = handler1.activate();
int result2 = handler2.activate();
int result3 = handler3.activate();
int result4 = handler4.activate();
ACE_ASSERT(result4 == 0);
ACE_ASSERT(result3 == 0);
ACE_ASSERT(result1 == 0);
ACE_ASSERT(result2 == 0);
handler2.wait();
handler1.wait();
handler3.wait();
handler4.wait();
return 0;
}
并且当我把类成员name和参数name的类型都改成string,然后HA_CommandHandler handler4(“hehe”)初始化--但输出的是黑屏--
{public:
int creat (int name)
{
for(;;)
cout<<name<<endl;
return 0;
}
};
class HA_CommandHandler:public ACE_Task_Base
{
public:
int name;
HA_CommandHandler (int name)
{
name = name;
}
virtual int svc(void)
{
cout<<name<<endl;
Conncet c1;
c1.creat(name);
return 0;
}
};
int ACE_TMAIN(int,ACE_TCHAR *[])
{
int x=1,y=2,z=3,j=4;
HA_CommandHandler handler1(x);
HA_CommandHandler handler2(y);
HA_CommandHandler handler3(z);
HA_CommandHandler handler4(j);
int result1 = handler1.activate();
int result2 = handler2.activate();
int result3 = handler3.activate();
int result4 = handler4.activate();
ACE_ASSERT(result4 == 0);
ACE_ASSERT(result3 == 0);
ACE_ASSERT(result1 == 0);
ACE_ASSERT(result2 == 0);
handler2.wait();
handler1.wait();
handler3.wait();
handler4.wait();
return 0;
}
并且当我把类成员name和参数name的类型都改成string,然后HA_CommandHandler handler4(“hehe”)初始化--但输出的是黑屏--