No, it's working as it should. The sample provided by zentara simply doesn't show it to you, as each loop runs too fast to allow the next thread to start before it terminates. Uncomment the select statement inside the for loop, and you'll see that they can all run side-by-side. (I'm guessing he forgot to uncomment it before posting.)
$ perl 968307.pl hello 1 from main hello 2 from main hello 3 from main hello 4 from main hello 5 from main hello 6 from main hello 7 from main hello 8 from main hello 9 from main hello 10 from main hello 1 from thread 1 hello 1 from thread 2 hello 1 from thread 3 hello 1 from thread 4 hello 1 from thread 5 hello 1 from thread 6 hello 1 from thread 7 hello 1 from thread 8 hello 1 from thread 9 all done, press the Enter key to exit hello 1 from thread 10 hello 2 from thread 1 hello 2 from thread 2 hello 2 from thread 3 hello 2 from thread 4 hello 2 from thread 5 hello 2 from thread 6 hello 2 from thread 7
Update: Swapped a couple of sentences so it makes more sense.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re^3: multithreading sample needed
by roboticus
in thread multithreading sample needed
by sweepy838
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |