Loading
Thread creation

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  How many way you create Thread in Java ?, what are those?


Ans)

There are two ways to create thread in java;

    • Implement the Runnable interface (java.lang.Runnable)
    • By Extending the Thread class (java.lang.Thread)

class RunnableThread implements Runnable {
        Thread runner;
        public RunnableThread(String threadName) {
                runner = new Thread(this, threadName);
                runner.start();
        }
        public void run() {
        }
}
class MyThread extends Thread {
        MyThread() {
        }
        MyThread(String threadName) {
                super(threadName); // Initialize thread.
                start();
        }
        public void run() {
        }
}



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

Thread creation


Thread creation

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free