//===============================================================
// B1 class runs under one thread 
// B2 object 1 runs under another thread
// B2 object 2 runs under yet another thread
//===============================================================
public class B1pgm
{
    public static void main(String[] args)
    {
        Class  c = B1pgm.class;                     //get reference to my class
        Thread t = Thread.currentThread();          //get reference to my thread

        System.out.println("This class name is: "   + c.getName() +
            ".   It is running under thread name: " + t.getName() + "\n");    

        B2class obj1 = new B2class();                 //create a thread 
        obj1.start();                                 //start it

        B2class obj2 = new B2class();                 //create another thread 
        obj2.start();                                 //start it
    }
}

class B2class extends Thread 
{
    public void run( )                              //the run method
    {
        Class  c = B2class.class;                   //get reference to my class
//or    Class  c = this.getClass();                 //same as prev. line

        Thread t = Thread.currentThread();          //get reference to my thread

        System.out.println("This class name is: " + c.getName() +
            ". with object reference: " + Integer.toHexString(System.identityHashCode(this)) +
            ". It is running under thread name: " + t.getName() );    
    }
}