Problem 我有個透過JNA去存取硬體資料的程式: public interface Bus extends Library { Bus INSTANCE = ( Bus ) Native . loadLibrary ( "buslib" , Bus. class ) ; boolean sendData ( byte bus, byte data [ ] ) ; boolean getData ( byte bus, byte data [ ] ) ; } public boolean sendData ( byte bus, byte data [ ] ) { synchronized ( Bus. class ) { return Bus. INSTANCE . sendData ( bus, data ) ; } } public boolean getData ( byte bus, byte data [ ] ) { synchronized ( Bus. class ) { return Bus. INSTANCE . getData ( bus, data ) ; } } 某天有了需要做存取控管需求,因此我在Bus Library介面上增加了兩個methods: boolean lockBus ( byte bus ) ; boolean releaseBus ( byte bus ) ; 而sendData中,在實際請求前會先lockBus,使用後再releaseBus: public boolean sendData ( byte bus, byte data [ ] ) { synchronized ( Bus. class ) { try { boolean ret = false ; if ( ! ( ret = Bus. INSTANCE . lockBus ( bus ) ) ) { return ret ; } return Bus. INSTANCE . sendData...