1 Usewarnings;2 UseStrict;3 UseThreads;4 5 Subtest{6 Print "Hello, world!\n.";7 return(qw/1 2 3 4 'a'/);8 }9 Ten #return to List Method 1 One my($t 1) = Threads->new ('TEST'); A Print $t 1-Join,"\ n"; - - #return to list Method 2 the # - my $t 2= Threads->new ({'Context'='List'},'TEST'); - Print $t 2-Join,"\ n"; - + #returns a single value - my $t 3= Threads->new ('TEST'); + Print $t 3-Join,"\ n"; A getc();
For a function call, if you want to get a return list, you should use a @values to get the return value:
1 #eg.2 my @values= &test;3 #If you return a list in a function call, such as you get the return value with a $value, you should get the value of the last element of the list4 #eg.5 my $value= (1,2,3,4 'a');6 Print $value;7 #result: ' A '8 #注意, this is the same as my $value = 1,2,3,4, ' a ';9 #
In multi-threaded, to get the thread to return the process, then call the Join method, if it is not necessary to get the return value, to call the detach method, if two are not called, you will receive a warning.
In general, you should call the Join/detach method.
2.Perl Multithreading: Threads (thread return value)