小编Roh*_*lik的帖子

如何执行线程安全获取然后使用ConcurrentHashMap删除?

在一次采访中,我被要求检查以下代码是否按预期工作.

ConcurrentHashMap<Integer, Integer> chm = new ConcurrentHashMap<>();

if (chm.get(key) != null) {
    chm.get(key).doSomething();
    chm.remove(key);
}
Run Code Online (Sandbox Code Playgroud)

根据JavaDocs,get返回上次完成的更新操作的值.因此,如果线程1已经被调用,chm.remove(key)并且如果线程2进入if语句并且即将调用get方法,那么我们可能会得到一个异常.它是否正确?

我怎样才能使这个线程安全?

java concurrenthashmap

7
推荐指数
2
解决办法
7504
查看次数

ES2015导出内部功能

我正在学习ES2015的导出功能.我尝试在网上理解它,但我的疑虑仍未解决

当我在匿名函数中声明导出时,jshint显示以下错误(至少在Intellij插件中):

E053出口申报必须在全球范围内.

相反,JSHint总是要求在Anonymous函数中包含整个代码.如果我按以下方式编写代码:

export const MY_CONSTANT = 1000;
(function(){
   'use strict';
    //Complete code goes here
}();
Run Code Online (Sandbox Code Playgroud)

我们必须在页面的顶部和底部编写大量代码.某些代码将从文件之间跳转到页面的开头(或结尾).

javascript export es2015

5
推荐指数
1
解决办法
917
查看次数

安装 APC 时出错

安装 APC 时出现以下错误

我也遵循了https://wiki.bitnami.com/Components/PHP#How_to_install_APC_module.3f 中提到的指导方针,但同样的错误。

我正在尝试将它安装在 Google App Engine 中 Wordpress 的 Bitnami 图像中。

         pecl install apc
        WARNING: configuration download directory "/tmp/pear/download" is not writeable.  Change download_dir config variable to a writeable dir to avoid this warning
        Cannot install, php_dir for channel "pecl.php.net" is not writeable by the current user
        user@edudrona-prod-vm:~$ sudo pecl install apc
        downloading APC-3.1.13.tgz ...
        Starting to download APC-3.1.13.tgz (171,591 bytes)
        .....................................done: 171,591 bytes
        55 source files, building
        running: phpize
        Configuring for:
        PHP Api Version: …
Run Code Online (Sandbox Code Playgroud)

wordpress caching apc apcu

5
推荐指数
0
解决办法
1253
查看次数

标签 统计

apc ×1

apcu ×1

caching ×1

concurrenthashmap ×1

es2015 ×1

export ×1

java ×1

javascript ×1

wordpress ×1