"targetWriter" is a method parameter, and should not be used for synchronization.
Code Path:server/src/main/java/org/apache/iotdb/db/engine/compaction/writer/AbstractCompactionWriter.java
Synchronizing on a class field synchronizes not on the field itself, but on the object assigned to it. So synchronizing on a non-final field makes it possible for the field’s value to change while a thread is in a block synchronized on the old value. That would allow a second thread, synchronized on the new value, to enter the block at the same time.
The story is very similar for synchronizing on parameters; two different threads running the method in parallel could pass two different object instances in to the method as parameters, completely undermining the synchronization.
i will try my best to do it,please assign to me