what is dollar sign mean in the stack frames when debugging?

eclipse, java

Solution

It is anonymous class.

An anonymous class is a local class without a name. An anonymous class is defined and instantiated in a single succinct expression using the new operator.

From the method name, it might be a Runnable.run() method.

public class Manager {
    
    public static void main(String[] args) {
        new Manager();
    }
    
    public Manager() {
        //                         this is anonymous class
        //                              |
        //                              V
        Thread thread = new Thread(new Runnable() {
            
            @Override
            public void run() {
                System.out.println("hi");
            }
        });
        thread.start();
    }
}

See

- Anonymous Classes

Problem

In the stack using Eclipse, sometimes I saw Manager$2.run() line : 278 What does $2 mean here?

Original source