Synchronized function takes too much time

https://github.com/igniterealtime/Smack/blob/master/smack-core/src/main/java/org /jivesoftware/smack/AbstractXMPPConnecti…

public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException

I don’t think we need a synchronized here

Yes we do need ‘synchronized’ here. All methods that change the state of an object need to be synchronized. Think about what would happen if e.g. connect() and disconnect(), or join() and leave(), are called concurrently. It’s also unclear to me how the execution time of a method is related to it being synchronized or not.