| Line | |
|---|
| 1 | BEGIN {
|
|---|
| 2 | eval { require Config; import Config };
|
|---|
| 3 | if ($@) {
|
|---|
| 4 | print "1..0 # Skip: no Config\n";
|
|---|
| 5 | exit(0);
|
|---|
| 6 | }
|
|---|
| 7 | }
|
|---|
| 8 |
|
|---|
| 9 | use Thread;
|
|---|
| 10 |
|
|---|
| 11 | use Thread::Specific qw(foo);
|
|---|
| 12 |
|
|---|
| 13 | sub count {
|
|---|
| 14 | my $tid = Thread->self->tid;
|
|---|
| 15 | my Thread::Specific $tsd = Thread::Specific::data;
|
|---|
| 16 | for (my $i = 0; $i < 5; $i++) {
|
|---|
| 17 | $tsd->{foo} = $i;
|
|---|
| 18 | print "thread $tid count: $tsd->{foo}\n";
|
|---|
| 19 | select(undef, undef, undef, rand(2));
|
|---|
| 20 | }
|
|---|
| 21 | };
|
|---|
| 22 |
|
|---|
| 23 | for(my $t = 0; $t < 5; $t++) {
|
|---|
| 24 | new Thread \&count;
|
|---|
| 25 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.