jak napisac program w c na watkach w Windowsie?
na linuxie mozna skorzystac z biblioteki <pthread.h>
#include <pthread.h>
#include <stdio.h>
void *threadFunc(void *arg)
{
char *str;
int i = 0;
str=(char*)arg;
while(i < 110 )
{
usleep(10000);
printf("threadFunc says: %s\n",str);
++i;
}
return NULL;
}
int main(void)
{
pthread_t pth; // this is our thread identifier
int i = 0;
pthread_create(&pth,NULL,threadFunc,"foo");
while(i < 100)
{
usleep(10000);
printf("main is running...\n");
++i;
}
printf("main waiting for thread to terminate...\n");
pthread_join(pth,NULL);
return 0;
}
kompilowalem za pomoca gcc nazwa.c -lpthread -o program i smigalo
jak to przerobic zeby sie odpalalo w Windowsie?
albo ma ktos jakis bardzo podstawowy przykladowy program?
