FileDocCategorySizeDatePackage
CurrentThreadDemo.javaAPI DocExample685Tue May 01 16:43:16 BST 2001None

CurrentThreadDemo

public class CurrentThreadDemo extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

       Thread t = Thread.currentThread();

       System.out.println("Current thread: " + t);

       // change main thread name

        t.setName("My main thread");
        System.out.println("After name change: " + t);

        try
          {
            for(int n = 5; n>0; n--)
              {
               System.out.println(n);
               Thread.sleep(1000);
               }
           }
         catch(InterruptedException e)
           {
            System.out.println("Main Thread interurrupted");
           }