Monday, September 26, 2016

Thread Exampale Of CurrentThread In java Programming

CurrentThread Exampale
class currentthreadex
{
       public static void main(String arg[])

     {

           Thread th=Thread.current.Thread();

          System.out.println("Current Thread Is:"+th);

         th.setName("exampale thread");

        System.out.println("After Name Change:"+th); //after change thread name of exampale thread

       try

      {

           for(int i=5;i>0;i--)

           {

                   System.out.println(i);

            }

      }

      catch(InterruptedException h)

     {

           System.out.println("Main Thread Interrrupted");


      }

     }

}

No comments:

Post a Comment