Note that there are some explanatory texts on larger screens.

plurals
  1. POPerl running two while loop subroutines in parallel
    text
    copied!<p>I am looking to run two subroutines in parallel, where both perform the same task on an android handset using ADB commands. With help from SO and other research I have produced the following code below, however I am new to multithreading and I get an error of 'Free to wrong pool' during execution. I am assuming I get this as I am using the $_ variable in both threads, is this correct? I am using Windows7 to run this, but my Perl interpreter crashes on running this script. Any guidance would be greatly appreciated. Thanks.</p> <pre><code>use strict; use Win32::OLE; use EFS_Handle; use HelperFunctions; use threads; #### Various ADB command sequences follow #### #### Start of multithread to run the same function on different android handsets #### my @jobs; push @jobs, threads-&gt;create( sub { print "\n\t" . curTime() . " :\t DUT Time at start of MPLMN search"; open my $fh1, '&gt;', "output.txt" or die "Cannot open output.txt: $!"; my $pid1 = open my $log1, "-|", "adb -s 42d8d7dd logcat"; system('adb -s 42d8d7dd shell input keyevent KEYCODE_ENTER'); while (&lt;$log1&gt;) { $fh1-&gt;print($_); last if m/Sorted scan results/; } kill "TERM", $pid1; close $log1; print "\n\t" . curTime() . " :\t DUT Time at End of MPLMN search\n"; } ); push @jobs, threads-&gt;create( sub { print "\n\t" . curTime() . " :\t REF Time at start of MPLMN search"; open my $fh, '&gt;', "output.txt" or die "Cannot open output.txt: $!"; my $pid = open my $log, "-|", "adb -s 0123456789ABCDEF logcat"; system('adb -s 0123456789ABCDEF shell input keyevent KEYCODE_ENTER'); while (&lt;$log&gt;) { $fh-&gt;print($_); last if m/EVENT_NETWORK_SCAN_COMPLETED/; } kill "TERM", $pid; close $log; print "\n\t" . curTime() . " :\t REF Time at End of MPLMN search\n"; } ); $_-&gt;join for @jobs; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload