Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object.
You get a lock for the class by declaring the method to be synchronized, but the method also has to be a static method. a static method that is synchronized ensures a class level lock. whereas synchronizing a non-static method gives a lock on the object of that class.
You get a lock for the class by declaring the method to be synchronized, but the method also has to be a static method. a static method that is synchronized ensures a class level lock. whereas synchronizing a non-static method gives a lock on the object of that class.
No comments:
Post a Comment