Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Conflito de Escrita em Matriz
#include <stdio.h> #include <stdlib.h> #include <pthread.h> int matriz[4][4]; void* funcaoA() { matriz[0][0] = matriz[0][0] + 10; return NULL; } void* funcaoB() { matriz[0][0] = matriz[0][0] * 2; return NULL; } void zerarMatriz() { for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { matriz[x][y] = 0; } } } int main() { for (int i = 0; i < 10; i++) { zerarMatriz(); pthread_t threadA, threadB; pthread_create(&threadA, NULL, funcaoA, NULL); pthread_create(&threadB, NULL, funcaoB, NULL); pthread_join(threadA, NULL); pthread_join(threadB, NULL); printf("Resultado %d\n", matriz[0][0]); } return 0; }
run
|
edit
|
history
|
help
0
pattern 17
B_141202_CTYPE
tgo
Adding sums of two 1-D arrays
ptr_tp_ptr
printing numbers without using loop
MyWall1
Project 3 Part 1 v1.7
str_ptr_to_fumc_v2
Vowel Assignment