Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Random by thread
#include <stdio.h> #include <stdlib.h> #include <pthread.h> int qualquer_coisa; void* incrementar(void* num) { int x, i; for (x = 0; x < 3; x++) { int temp = qualquer_coisa; for(i = 0; i < 10000; i++); qualquer_coisa = temp + 1; } return 0; } void* decrementar(void* num) { int x, i; for (x = 0; x < 3; x++) { int temp = qualquer_coisa; for(i = 0; i < 10000; i++); qualquer_coisa = temp - 1; } return 0; } int main() { int num_th1, num_th2; pthread_t th1, th2; qualquer_coisa = 10; pthread_create(&th1, NULL, incrementar, (void*) &num_th1); pthread_create(&th2, NULL, decrementar, (void*) &num_th2); pthread_join(th1, NULL); pthread_join(th2, NULL); printf("Resultado %d\n", qualquer_coisa); return 0; }
run
|
edit
|
history
|
help
0
Command Expressions in Gnu C
150113_ArrayOrdenado
150115_EsMatrizOrdenada
arrays vowles printing
ultimo cuestionario
Kous
MATRIZ DE CADENAS
Assignment 4 v3
MULTI-CAST
second P