Synchronized byte[0] in java multithreading

 

byte[] lock1 = newbyte[0];   

synchronized (lock1) { 

}

 

A zero-length byte array object will be more economical to create than any object - look at the compiled bytecode: it only takes 3 opcodes to generate a zero-length byte[] object, while Object lock = new Object() takes 7 line opcode.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326180579&siteId=291194637