in reply to Waking threads that do periodic checks
#!/usr/bin/perl use strict; use warnings; use threads; use Thread::Suspend; $|=1; my $TERM = 0; $SIG{'INT'} = $SIG{'TERM'} = sub { $TERM = 1; }; print "To terminate program, hit ctrl-^C\n"; sub start_thread { my @args = @_; print(join(' ', @args,)); } my $thr = threads->create(\&start_thread); $thr->join(); $thr->suspend(); $thr->yield(); sleep (1) until ($TERM); print ("\e[2K\e[?25h\n"); #to restore proper cursor behavior
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Waking threads that do periodic checks
by BrowserUk (Patriarch) on Sep 26, 2011 at 04:57 UTC |