Next 1.1 Creating threads Prev

Creating threads

Every multi-threaded program should include:

use threads;

New threads are created using:

threads->new(\&thread_sub, @sub_params)
which returns the thread object. A more complete example:
use threads; $thr1 = threads->new(sub { ... code 1 ... }); $thr2 = threads->new(sub { ... code 2 ... }, $param1, $param2);
create() is a synonym for new().

Next Perl Threads Prev