随笔分类 -  多线程多进程

摘要://main.cpp#include #include void worker(){ std::cout << "another thread";}int main(){ std::thread t(worker); std::cout << "main thread" << std::endl; t.join(); return 0;}编译:g++ main.cp... 阅读全文
posted @ 2014-01-13 21:25 helloweworld 阅读(220) 评论(0) 推荐(0)
摘要:一、传递一个参数。 #include #include using namespace std; void* thr_fn(void* arg){ int i = *(int*)arg; cout #include using namespace std; struct parameter{ char a; int i; float f;}; void* thr_fn(void* ar... 阅读全文
posted @ 2014-01-07 22:58 helloweworld 阅读(4338) 评论(0) 推荐(0)
摘要:多线程MultiThreading.c #include #include #include #include #define MAX 10 pthread_t thread[2];//线程ID pthread_mutex_t mut;//定义互斥锁变量 int number=0, i; v... 阅读全文
posted @ 2013-05-18 13:52 helloweworld 阅读(251) 评论(0) 推荐(0)
摘要:gcc test.c -lpthread 阅读全文
posted @ 2012-11-17 14:23 helloweworld 阅读(1852) 评论(0) 推荐(0)