I'm very curious in what multithreading is. I have heard the name battered around here and there in answers I have received on StackOverflow but I have no idea what it is, so my main two questions being what is it and how can I benefit from it?
EDIT:
Ok, since the first question didn't really get the response I was looking for I'll go with this..
I have never heard of 'threading' even in other languages. This is an example I have found on the internet:
#!/usr/bin/perl
use strict;
use warnings;
use threads;
use threads::shared;
print "Starting main program\n";
my @threads;
for ( my $count = 1; $count <= 10; $count++) {
my $t = threads->new(\&sub1, $count);
push(@threads,$t);
}
foreach (@threads) {
my $num = $_->join;
print "done with $num\n";
}
print "End of main program\n";
sub sub1 {
my $num = shift;
print "started thread $num\n";
sleep $num;
print "done with thread $num\n";
return $num;
}
I cant seem to understand what it is that it is doing. Could anyone shine any light? Regards, Phil