亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 4045 | 回復: 8
打印 上一主題 下一主題

windows下perl能啟動多少個線程? [復制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2007-02-12 13:03 |只看該作者 |倒序瀏覽
循環(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";
}

論壇徽章:
0
2 [報告]
發(fā)表于 2007-02-12 13:53 |只看該作者
沒用過windows下perl線程

ERRORS
    This Perl not built to support threads
        The particular copy of Perl that you're trying to use was not built
        using the "useithreads" configuration option.

        Having threads support requires all of Perl and all of the XS
        modules in the Perl installation to be rebuilt; it is not just a
        question of adding the threads module (i.e., threaded and
        non-threaded Perls are binary incompatible.)

THREAD STACK SIZE
    The default per-thread stack size for different platforms varies
    significantly, and is almost always far more than is needed for most
    applications. On Win32, Perl's makefile explicitly sets the default
    stack to 16 MB; on most other platforms, the system default is used,
    which again may be much larger than is needed.

    By tuning the stack size to more accurately reflect your application's
    needs, you may significantly reduce your application's memory usage, and
    increase the number of simultaneously running threads.

    N.B., on Windows, Address space allocation granularity is 64 KB,
    therefore, setting the stack smaller than that on Win32 Perl will not
    save any more memory.

[ 本帖最后由 helbreathszw 于 2007-2-12 14:03 編輯 ]

論壇徽章:
0
3 [報告]
發(fā)表于 2007-02-12 13:56 |只看該作者
This Perl not built to support threads   ????

論壇徽章:
0
4 [報告]
發(fā)表于 2007-02-12 14:09 |只看該作者
my $thread_time_start=gettimeofday;
        $threadlist[$i]=threads->create({'stack_size' => N*4096},"updateData",$account[$i],$run_num);
N自己設(shè),我也不知道你的那個程序占用多少。

論壇徽章:
0
5 [報告]
發(fā)表于 2007-02-12 15:30 |只看該作者
$threadlist[$i]=threads->create({'stack_size' => 1000*4096},"updateData",$account[$i],$run_num);
把N設(shè)置成1000還是不行!
并發(fā)100個線程的時候,提示"Can't call method "tid" on an undefined value at first1.cgi line 40.
A thread exited while 92 threads were running."

[ 本帖最后由 herolyh 于 2007-2-12 15:34 編輯 ]

論壇徽章:
0
6 [報告]
發(fā)表于 2007-02-13 15:16 |只看該作者
線程是5.8以后才加入的,5.8以前都要自己編譯才可以使用
樓主出錯可能是硬件限制或者解釋器本身的限制吧
畢竟一次用100個線程的程序恐怕也不是很多(BT等P2P的軟件除外)
或者你使用進程+線程的方法獲取更多可用線程

論壇徽章:
1
2015年辭舊歲徽章
日期:2015-03-03 16:54:15
7 [報告]
發(fā)表于 2007-02-13 16:14 |只看該作者
我記得限制是 64,好像。

論壇徽章:
0
8 [報告]
發(fā)表于 2007-02-13 19:18 |只看該作者
原帖由 flw 于 2007-2-13 16:14 發(fā)表
我記得限制是 64,好像。


Win32 大概是100線程左右吧,其它平臺各異。

CPAN 上有個更新的 threads 模塊一直在維護, 非;钴S,
包括 threads::shared。

包括一些新的功能加入,
而且還可以指定堆棧大小,從而可以創(chuàng)建更多的線程,只要你有足夠的內(nèi)存。
需要提示的是,Perl5.8 的線程機制非常耗內(nèi)存,能少開,盡量少開吧,
沒人歡迎一吃就是幾百兆的程序  

強烈建議你下載最新版本,重新編譯,以后可能會替換Perl內(nèi)置的threads模塊。

http://search.cpan.org/~jdhedden/

論壇徽章:
0
9 [報告]
發(fā)表于 2007-02-13 19:57 |只看該作者
Win32下是一百個,而且是所有Perl進程公用這100個線程。
Win32下線程比進程的內(nèi)存占用還是要少很多,開100個線程是沒問題的,但你要開100個進程就有的好看了。

[ 本帖最后由 戰(zhàn)鷹 于 2007-2-13 19:59 編輯 ]
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP