Mercurial > hg > Members > taiki > cbc_test
view cbc_thread/cbc_thread_test.c @ 9:2ce34a5ff69b default tip
add pointer test
author | taiki |
---|---|
date | Tue, 08 Jan 2013 12:34:40 +0900 |
parents | 1d2839ecabda |
children |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <pthread.h> typedef struct _DS { int thread_no; int *data; } DS; __code start1() { printf("into cs \n"); } void start(void *arg) { DS *ds = (DS*)arg; printf("thread%d:\t%d\n", ds->thread_no, ds->data[0]); goto start1(); } int main(int argc, char* argv[]) { pthread_t handle; DS ds; int data[2]; int i=0; for (; i < 2; i++) data [i] = i; ds.thread_no = 1; ds.data = data; pthread_create(&handle, NULL, (void*)start, (void*)&ds); pthread_join(handle, NULL); return 0; }