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.
↧