docs
[mirrors/Programs.git] / perl / thr.pl
CommitLineData
21c4e167
H
1#!/usr/bin/env perl
2use strict;
3use warnings;
4use LWP::Simple;
5use threads; # ('exit' => 'threads_only');
6
7sub alrm_sleep {
8 my $thr = threads->create(sub {
9 $SIG{'TERM'} = sub {
10 threads->exit(0);
11 };
12 }
13 $SIG{'ALRM'} = sub {
14 $thr->kill('TERM');
15 }
16 alarm(3);
17 $thr->join();
18}
19
20my $thr = threads->create(sub {
21 $SIG{'KILL'} = sub {
22 print("thread is dying\n");
23 threads->exit();
24 };
25
26 print("new thread\n");
27 getprint('http://192.168.2.1:2/');
28 print("thread end\n");
29});
30
31$thr->kill('SIGKILL');
32print("killed thread");
33$thr->join();
This page took 0.156372 seconds and 4 git commands to generate.