All run instances actually share the same "pointer" into the method lookup table. However, the exact size of the object depends on the contents of run and ... above it. An anonymous class created by the compiler provides space for storing variables referenced by the run method, in addition to space for storing a reference to the this object of the surrounding class.
For instance,
private String name; void thisIsCalledManyTimes(){ final int value1 = 123; final double value2 = 456.789. someObject.executeIfNecessary( new Runnable(){ void run(){ System.out.println(name);
reserves space in the object to store value1 , value2 and this ; each instance of an anonymous object will receive a copy of these variables.
source share