00001 #include <cc++/thread.h>
00002 #include <cstdio>
00003 #include <cstring>
00004 #include <iostream>
00005
00006 #ifdef CCXX_NAMESPACES
00007 using namespace std;
00008 using namespace ost;
00009 #endif
00010
00011
00012
00013 class Child: public Thread
00014 {
00015 public:
00016 Child()
00017 { }
00018 void run()
00019 {
00020 cout << "child start" << endl;
00021 Thread::sleep(3000);
00022 cout << "child end" << endl;
00023 }
00024 void final()
00025 {
00026
00027 }
00028 };
00029
00030 class Father: public Thread
00031 {
00032 public:
00033 Father()
00034 { }
00035 void run()
00036 {
00037 cout << "starting child thread" << endl;
00038 Thread *th = new Child();
00039 th->detach();
00040 Thread::sleep(1000);
00041 cout << "father end" << endl;
00042 }
00043 void final()
00044 {
00045
00046
00047 memset(this,0,sizeof(*this));
00048 }
00049 };
00050
00051 int main(int argc, char* argv[])
00052 {
00053 cout << "starting father thread" << endl;
00054 Father *th = new Father();
00055 th->start();
00056 Thread::sleep(10000);
00057
00058 return 0;
00059 }
00060