spBase
読み取り中…
検索中…
一致する文字列を見つけられません
simple_thread.c
#include <sp/spThread.h>
#define NUM_THREAD 8
#define NLOOP 10000
spThreadReturn thread(void *data)
{
int n;
int *thread_index = (int *)data;
for (n = 0; n < NLOOP; n++) {
printf("thread %d: n = %d\n", *thread_index, n);
}
printf("thread %d done\n", *thread_index);
return SP_THREAD_RETURN_SUCCESS;
}
int main(int argc, char *argv[])
{
int i;
int thread_indexes[NUM_THREAD];
void *hthreads[NUM_THREAD];
for (i = 0; i < NUM_THREAD; i++) {
thread_indexes[i] = i;
hthreads[i] = spCreateThread(0, 0, thread, &thread_indexes[i]);
}
for (i = 0; i < NUM_THREAD; i++) {
printf("wait thread %d...\n", i);
spWaitThread(hthreads[i]);
printf("wait thread %d done\n", i);
}
printf("done\n");
return 0;
}
void * spCreateThread(long stacksize, int priority, spThreadFunc func, void *data)
long spWaitThread(void *handle)