1.

Explain The Method Of Runnable Interface With Example.

Answer»
  • In this METHOD of creating thread, we have to implement the Runnable interface and implement the RUN() method in our class.
  • We have to create an object of our class.
  • Then we you have to pass the reference of that object for creating a new object of Thread
  • Invoke the start method using this Thread object which will create a new thread of execution.
    For example
    public class MYTHREAD implements Runnable
    {
    public VOID run()
    {
    // code to execute under the thread
    }
    public STATIC void main(String [] args)
    {
    MyThread c = new NewThread();
    Thread t = new Thread(c);
    t.start();
    }
    }



Discussion

No Comment Found