- 論壇徽章:
- 0
|
循環(huán)啟動線程并回收,但是如果線程數(shù)目為100個,就會報錯,提示“Can't call method "tid" on an undefined value at first1.cgi line 40
A thread exited while 95 threads were running.”
怎么回事呢?
代碼如下:
for(my $i=0;$i<$thread_num;$i++) {
my $thread_time_start=gettimeofday;
$threadlist[$i]=threads->create("updateData",$account[$i],$run_num);
my $tid=$threadlist[$i]->tid;
# print "the start time of thread_",$tid," is ",$thread_time_start,"\n";
# print LF "the start time of thread_",$tid," is ",$thread_time_start,"\n";
}
# 回收啟動的線程
foreach (@threadlist) {
$_->join();
my $thread_time_end=gettimeofday;
# print "the end time of thread_",$_->tid," is ",$thread_time_end,"\n";
# print LF "the end time of thread_",$_->tid," is ",$thread_time_end,"\n";
} |
|