Skip to content

Instantly share code, notes, and snippets.

@austa
Last active December 17, 2015 12:09
Show Gist options
  • Save austa/5607205 to your computer and use it in GitHub Desktop.
Save austa/5607205 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <pthread.h>
void *thread_proc(void *param);
int main(int argc, char *argv[])
{
pthread_t tid;
int result, i;
if ((result = pthread_create(&tid, NULL, thread_proc, NULL)) != 0) {
fprintf(stderr, "%s\n", strerror(result));
exit(EXIT_FAILURE);
}
printf("Ana thread sonlaniyor!..\n");
pthread_exit(NULL);
return 0;
}
void *thread_proc(void *param)
{
int i;
for (i = 0; i < 10; ++i) {
printf("Thread: %d\n", i);
sleep(1);
}
pthread_exit(NULL);
return NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment