When I want to define synchronized block in a class which implements Filter interface is there any difference between synchronized (Myclass.class) and synchronized (this). A I know one object will create from Filters classes
Asked
Active
Viewed 26 times
0
-
`synchronized(Myclass)` doesn't compile. – M. le Rutte Oct 15 '17 at 19:22
-
1One doesn't compile and the other does. If you mean synchronized(Myclass.class), then it synchonizes on the Myclass class whereas the other synchonizes on this instance of Myclass. Doesn't make a big difference in case of a filter, since it's nomally a singleton, but makes a huge difference if there are multiple instances of Myclass. – JB Nizet Oct 15 '17 at 19:23