• Tuesday, September 9, 2014

    Java - Thread

    Thread in Java

    What is Thread?

    Thread is a class, an independent path of execution within a program. A thread execute the provided code(Task) in new process, so the thread run concurrently with your program. 
    Usually thread is use for connectivity(i.e. Networking, Internet, Bluetooth), timer, i/o operation.
    It can be extends with your program, and a run method must be override, and that override method run when thread starts.
    Thread class is define in:  java.lang.Thread

    When thread object is made then a runnable object must pass inside thread object. I discuss runnable object in next lesson.


    class ThreadTest extends Thread
         public void run()
               System.out.println("Thread starts...");
         public static void main(String args[])
              ThreadTest t=new ThreadTest();

    Syed Masoom Rizvi

    Author & Editor

    Hi, This is Syed Masoom Rizvi, who is continue exploring the world of programming ,programming and programming... :)


    Post a Comment