Opened 5 years ago

Last modified 3 years ago

#792 new defect

Threaded script output is in the wrong order

Reported by: szabgab Owned by:
Priority: major Milestone:
Component: editor Version: 0.95
Keywords: Cc:

Description

Running the following simple script in Padre with the outptut set to be the internal window will show the output in the wrong order

use strict;
use warnings;

#$| = 0;

use Time::HiRes qw(sleep);
use threads;
#use threads::shared;

my $t = threads->create(\&prt, 3);

foreach my $i (0..4) {
	my $r = rand();
	print "main $$ $i $r\n";
	sleep $r;
}
print "joined: " , $t->join, "\n";

sub prt {
	print "prt  $$ started\n";
	foreach my $i (0..$_[0]) {
		my $r = rand();
		print "prt  $$ $i $r\n";
		sleep $r;
	}
	return 'z';
}

Output:

prt  6861 started
prt  6861 0 0.985413604722456
prt  6861 1 0.58135624751182
prt  6861 2 0.558220611457852
prt  6861 3 0.398723572349759
main 6861 0 0.078701744628237
main 6861 1 0.90126634491341
main 6861 2 0.617402522863028
main 6861 3 0.104640960084858
main 6861 4 0.322318606206938
joined: z

When using the external output window or when running from the command line I get the expected random order:

prt  6859 started
main 6859 0 0.355495126060308
prt  6859 0 0.322238944311724
prt  6859 1 0.135644333527551
main 6859 1 0.572476746837737
prt  6859 2 0.78271155435699
main 6859 2 0.230260133083117
main 6859 3 0.606436307166355
prt  6859 3 0.837214991773131
main 6859 4 0.979939686495602
joined: z

Change History (3)

comment:1 Changed 4 years ago by wwe

  • Version changed from 0.51 to 0.82

still the same on 0.82 (XP/Strawberry 5.12)

comment:2 Changed 4 years ago by zenogantner

Same behavior here on Ubuntu 10.04/Perl 5.10.1 with r14047.

comment:3 Changed 3 years ago by bowtie

  • Version changed from 0.82 to 0.95

I Concure

Note: See TracTickets for help on using tickets.