Closed ehsanjavadynia closed 6 years ago
I will look at a better way of synchronising the open/close mechanism on a connection but can I suggest you also look at another strategy in your code. Opening/closing connections is expensive, in high performance systems you should really look to mitigate this by cacheing connections and re-using them.
I've come to the conclusion that in most cases, the library is being overly aggressive with regards to synchronisation and it is hurting performance. So I have removed a number of synchronized decorators including the ones mentioned in this ticket.
Expected Behavior
ModbusTCPMaster connect and disconnect methods not to be synchronized
Actual Behavior
ModbusTCPMaster connect and disconnect are synchronized
Specifications
We want to use j2mod modbus in a servlet. But the problem is that the connect and disconnect methods are synchronized and they degrade our servlet performance.
Is it possible for us to make connect and disconnect methods asynchronous(if we make a new connection handler and a modbus master class on each servlet call)?