1、线程间通信(参考安卓源码InputTransport.cpp)
#include <pthread.h> #include <sys/types.h> /* See NOTES */ #include <sys/socket.h> #include <stdio.h> #include <unistd.h> static const size_t SOCKET_BUFFER_SIZE = 32 * 1024; void *pthread_1(void *arg) { int fd = *((int *)arg); char buf[512]; int len; int cnt = 0; while (1) { len = sprintf(buf, "hello, main pthread, cnt = %d", cnt++); write(fd, buf, len); len = read(fd, buf, 500); buf[len] = '