Using threads in perl

Remember setting threads in your ./Configure, cause it’s not compiled by default!

Example:

#!/usr/bin/perl

use Thread;

new Thread \&test_sub;

sub test_sub {
while(1) {
sleep 2;
print “TestSUB\n”;
}
}

while(1){
sleep 3;
print “NormalProc\n”;
}

For more information, see http://www.xav.com/perl/lib/Thread.html

Dette indlæg blev udgivet i Knowledge Base, Old Base, Programmering. Bogmærk permalinket.

Skriv et svar