Firstly, what this program is doing is instantiating a new thread from within your main method that prints text to the console.
Now, the Thread class constructor accepts a class that implements the Runnable interface. We can supply a instance to the Thread constructor two ways. We can use a concrete class that implements Runnable or supply an Anonymous Inner Class. In this case you are doing the later.
According to the Oracle Documentation on Anonymous inner classes. Anonymous classes enable you to make your code more concise. They enable you to declare and instantiate a class at the same time. They are like local classes except that they do not have a name. Use them if you need to use a local class only once.
new Thread(new Runnable() {
public void run() {
System.out.print("bar");
}
}).start();
So you can think of this as passing a class of the Runnable interface which satisfies the contract by overriding the run method and defining it within the constructor parameter.