实际开发中只需要会玩互斥锁就够了
这边在CentOS中创建一个c文件,其中创建两个线程,分别对一个int变量做处理
#include
#include
#include...(time(0));
//创建线程1
pthread_create(&pthid,0,thread_start,(void *)1);
//创建线程2
pthread_create...pthread_mutex_init(&foo_mutex, NULL);
//创建线程1
pthread_create(&pthid,0,thread_start,(void *)1)...;
//创建线程2
pthread_create(&pthid,0,thread_start1,(void *)2);
usleep(20000);
//销毁锁
pthread_mutex_destroy...JNI创建线程
在JNI中,我们在java层调用native方法,是在一个线程中的,所以主线程中调用native方法,如果耗时严重,有必要在native层使用多线程,下面介绍native中使用多线程的方法