Quantcast
Channel: Neue Beiträge
Viewing all articles
Browse latest Browse all 10

Can you spot the race condition?

$
0
0
Englisch

The example program below contains a common threading error. When I first started programming with threads, this was the first race condition to bite me. The program uses Pthreads because that's what I was using at the time.

The program creates four threads that each print a message with a unique id number. Like many threaded programs, it sometimes works correctly even though it contains an error. Can you spot the race condition?


Viewing all articles
Browse latest Browse all 10

Latest Images



Latest Images