move dirs

This commit is contained in:
2023-09-26 22:05:13 +03:00
parent 5414fa8538
commit 55d774e7d5
190 changed files with 0 additions and 0 deletions

31
code/C/thread.c Normal file
View File

@@ -0,0 +1,31 @@
/* https://www.geeksforgeeks.org/multithreading-in-c/ */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
int g = 0;
void *my_thread(void *vargp) {
int *id = (int *)vargp;
static int s = 0;
++s;
++g;
printf("Thread ID: %d, Static: %d, Global: %d\n", *id, ++s, ++g);
}
int main() {
pthread_t tid;
int i;
for (i = 0; i < 3; i++)
pthread_create(&tid, NULL, my_thread, (void *)&tid);
pthread_exit(NULL);
return 0;
}