in reply to Did I create a concurrent program?

Yes. 10 copies of your sub will run concurrently. And each will see it's own unique value of the closure $j.

As posted though, the process will die as soon as the last thread is started, with the infamous:

Perl exited with active threads: 10 running and unjoined 0 finished and unjoined 0 running and detached

warning, as you are not waiting for them to finish. However, the spawned mv processes will (probably, I've not used iThreads on *nix), continue running to completion.

In effect, you have coded the equivalent of:

no threads; my $j = 0; for (1..10) { $j++; `mv ./a_file$j /home/user/dir 2>&1 &`; }

Whether you will gain any throughput from using concurrency will depend upon your system, no of processors, disks, etc. but as Corion pointed out, any gains will likely be quite small.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."