#! perl -sw use strict; use threads; use threads::shared; my $sem :shared; open my $fh, '>:raw', 'junk.dat' or die $!; $_->join for map { async { for my $i ( 0 .. 999 ) { lock $sem; seek $fh, $i*320 + ($_-1)*80, 0; print $fh $_ x 79, "\n"; } }; } 1 .. 4; close $fh; open $fh, '<', 'junk.dat' or die $!; print while <$fh>; close $fh; __END__ C:\test>t-write.pl 111111111111111111111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333333333333333333333 444444444444444444444444444444444444444444444444444444444444444444444444444444 111111111111111111111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333333333333333333333 444444444444444444444444444444444444444444444444444444444444444444444444444444 111111111111111111111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333333333333333333333 444444444444444444444444444444444444444444444444444444444444444444444444444444 111111111111111111111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333333333333333333333 444444444444444444444444444444444444444444444444444444444444444444444444444444 111111111111111111111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333333333333333333333 444444444444444444444444444444444444444444444444444444444444444444444444444444 111111111111111111111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333333333333333333333 444444444444444444444444444444444444444444444444444444444444444444444444444444 111111111111111111111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333333333333333333333 444444444444444444444444444444444444444444444444444444444444444444444444444444 111111111111111111111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333333333333333333333 444444444444444444444444444444444444444444444444444444444444444444444444444444 111111111111111111111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333333333333333333333 444444444444444444444444444444444444444444444444444444444444444444444444444444 111111111111111111111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333333333333333333333 444444444444444444444444444444444444444444444444444444444444444444444444444444 ...