//author:DriverMonkey
//phone:13410905075
//mail:bookworepeng@Hotmail.com
//qq:196568501
#include <pthread.h>
#include <unistd.h>
#include <iostream>
using namespace std;
static void *thead_GUI(void *arg);
static void *thread_logic(void *arg);
int main ()
{
pthread_t thread_GUI_id = 0;
pthread_t thread_logic_id = 0;
pthread_create (&thread_GUI_id, NULL, &thead_GUI, NULL);
pthread_create (&thread_logic_id, NULL, &thread_logic, NULL);
pthread_join (thread_GUI_id, NULL);
pthread_join (thread_GUI_id, NULL);
return 0;
}
static void *thead_GUI(void *arg)
{
int sleep_count = 0;
sleep_count = 3;
while(sleep_count--)
{
cout<<"thead_GUI: sleep_count = "<<sleep_count<<endl;
sleep(sleep_count);
}
}
static void *thread_logic(void *arg)
{
int sleep_count = 0;
sleep_count = 3;
while(sleep_count--)
{
cout<<"thread_logic: sleep_count = "<<sleep_count<<endl;
sleep(sleep_count);
}
}
LINUX 创建线程例子
最新推荐文章于 2023-03-11 14:50:17 发布