Quantcast
Channel: Simple multithreading in C - Stack Overflow
Browsing all 3 articles
Browse latest View live

Answer by prog-fh for Simple multithreading in C

This is a classic situation where all the threads share the same data, but should not.Here you pass &i to each thread, thus all of them refer to the same location in memory: the only one where the...

View Article



Answer by Paul Hankin for Simple multithreading in C

You're passing in the address of i to each of the threads, so they each read the current state of i (and without synchronization, so the results are unpredictable if not undefined).Instead, you need to...

View Article

Simple multithreading in C

I try to implement a function which prints each thread number . For example thread 0 prints 0 thread 1 prints 1 and so on , but not in this expected order.What I have been trying so far is this#include...

View Article
Browsing all 3 articles
Browse latest View live




Latest Images