0

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • `synchronized(Myclass)` doesn't compile. – M. le Rutte Oct 15 '17 at 19:22
  • 1
    One 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

0 Answers0