extras/threading_example: add intro

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2025-09-23 15:51:33 +03:00
parent e41e132b60
commit b259adff52

View file

@ -1,5 +1,24 @@
"""
This program adds
This program runs a loop that adds +1 to different cells in an array.
Run it as:
python threading_example.py WORKERS ITERATIONS
where WORKERS is the number of threads,
and ITERATIONS is how much work each thread does.
In the single threaded case, when N == 1, the 'counters' variable
below starts out as
[0, 0, 0]
then becomes
[1, 0, 0]
then
[1, 1, 0]
... and a little bit later
[2, 1, 1]
and at the end
[N, N, N]
What happens in the multi-threaded case, when N > 1? Try and see!
"""
import sys