diff --git a/extras/threading_example/threading_example.py b/extras/threading_example/threading_example.py index 9766682..5b8fa73 100644 --- a/extras/threading_example/threading_example.py +++ b/extras/threading_example/threading_example.py @@ -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