小编H-B*_*Bar的帖子

npx create-react-app 似乎不起作用

我正在尝试通过运行以下命令来创建 React 应用程序样板

npx create-react-app my-app

我收到以下错误

npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:\Users\dejean\AppData\Roaming\npm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\dejean\AppData\Roaming\npm'   
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\dejean\AppData\Local\npm-cache\_logs\2023-06-27T18_53_22_682Z-debug-0.log

Run Code Online (Sandbox Code Playgroud)

我使用节点 18.16.1 和 npm 9.5.1

node.js npm reactjs create-react-app npx

3
推荐指数
1
解决办法
5734
查看次数

为什么我的所有线程都使用相同的锁?

我最近遇到了这个代码片段

class Counter2 implements Runnable{

    private int value = 0;

    
    private Integer lock = 0;

    

    public void increment(){
        try {
            Thread.sleep(20);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        value++;
    }

    public void decrement(){
        value--;
    }

    public int getValue() {
        return value;
    }

    @Override
    public void run() {
        synchronized(lock) {
            this.increment();
            System.out.println(String.format("%s incremented value, value = %s", Thread.currentThread().getName(), this.value));
            this.decrement();
            System.out.println(String.format("%s decremented value, value = %s", Thread.currentThread().getName(), this.value));
        }
    }
}
public class Part8_synchronized_keyword_1 {
    
    public static void main(String[] args) { …
Run Code Online (Sandbox Code Playgroud)

java concurrency synchronized

0
推荐指数
1
解决办法
69
查看次数