setting the thread's name when Thread object is created?
<p>I'm new to Java. Can anyone explain what happens in the main method??</p>

<pre><code>class Demo {
    public static void main(String []args) {
        //setting a name using the constructor
        Thread t=new Thread("main"){
            //what is this? a static block?? need an explanation to this.
            {setName("DemoThread");} 
        };
        //output is DemoThread. Since it set the name again.
        System.out.println(t.getName());
    }
}
</code></pre>
