这两天开始看一下Perl 的Multi-thread. 以下代码是从perldoc perlthrtut 中copy出来的,但是在我的本地测试中并不会hang (windows 和 Linux). use threads; my $a : shared = 4; my $b : shared = "foo"; my $thr1 = threads->new(sub { lock($a); sleep 20; lock($b); }); my $thr2 = threads->new(sub { lock($b); sleep 20; lock($a); }); Th...
by Eleswen - Perl - 2008-03-18 17:21:53 阅读(3249) 回复(2)
这个贴子(http://bbs.chinaunix.net/thread-1351797-1-1.html)可能是require引起的,所以我想把代码写在一个文件里试试,又出了新的错。郁闷 1 #!/usr/bin/perl 2 # 3 #load 4 use DBI; 5 use strict; 6 use warnings; 7 #use diagnostics; 8 use URI; 9 use threads; 10 11 require("qeesoo_prehandle.conf"); 12 our $log; 13 our $dbh_gdas; ...
问题同 http://www.perlmonks.org/?node_id=783017 一样 就直接照搬那人的了 无cookie情况下输入网站 并点击下载 图片下载下来了 但是 windows 对话框 Perl Command Line Interpreter 遇到问题需要关闭。我们对此引起的不便表示抱歉。 perl 显示错误如下: Attempt to free non-existent shared string '_TK_RESULT_', Perl interpreter: 0x2e3642c at C:/Perl/lib/Tk.pm line 252. Attempt to free non-existent shared string...
http://www.llnl.gov/computing/tutorials/pthreads/ [ 本帖最后由 cjaizss 于 2006-5-27 16:33 编辑 ]
10个线程,每个调用一个子函数100次,一共1000次 子函数: sub Get($){ my $url=shift; my $agent = LWP::userAgent->new; my $request=HTTP::Request->new(GET =>$url); my $response=$agent->request($request); $response->is_success or warn "$url: $response->message\n" and exit 1; 。。。 undef $agent; undef $request; } 不是很明白线程,只是在全启动后...
由于程序中需要使用OLE,但是OLE好像不是线程安全的,只要引入OLE在线程释放的时候就会报错 请问各位老大如何在多线程环境中使用OLE? #!/usr/bin/env perl use threads; use Win32::OLE; sub sub1 { $a = 0; for (my $I = 0; $I < 100; $I++) { print "is $I\n"; } &...