略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: pht\AtomicInteger::unlock

2024-12-27

pht\AtomicInteger::unlock

(PECL pht >= 0.0.1)

pht\AtomicInteger::unlockReleases the atomic integer's mutex lock

说明

public pht\AtomicInteger::unlock ( void ) : void

This method will release the mutex lock associated with the atomic integer.

参数

此函数没有参数。

返回值

No return value.

范例

Example #1 Grouping together an atomic integer's operations (requiring a mutex lock)

<?php

use pht\AtomicInteger;

$atomicInteger = new AtomicInteger(2);

// assumes $atomicInteger is being used by multiple threads
$atomicInteger->lock();
$atomicInteger->set($atomicInteger->get() * 2); // double the value
$atomicInteger->unlock();

var_dump($atomicInteger->get());

以上例程会输出:

int(4)
add a note add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/pht-atomicinteger.unlock.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3