简体   繁体   English

未定义的子程序 &main::unlock

[英]Undefined subroutine &main::unlock

I wrote this:我是这样写的:

use threads;

    lock($lock);
        cond_wait($full,$lock) while($threads == $max_thread);
        $threads++;
    unlock($lock);

After running this code, I am given the error:运行此代码后,出现错误:

Undefined subroutine &main::unlock called at ./pages.pl line 222, <FH> line 1.`

How can I resolve this?我该如何解决这个问题?

perlthrtut限制条件

Note that there is no unlock() function - the only way to unlock a variable is to allow it to go out of scope.请注意,没有 unlock() 函数 - 解锁变量的唯一方法是允许它超出范围。

So,所以,

{
    lock($lock);
    cond_wait($full,$lock) while($threads == $max_thread);
    $threads++;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM