my @end_ne :shared = (0) x NTHREADS; ... sub threadHandler{ my $tid = threads->tid; ... if( $end_ne[ $tid ] ) { return; } ... } ... if( time() > ... ) { $end_ne[ $someTid ] = 1; }