Interviewer And Interviewee Guide

Java Multi-Threading Interview Question:

Explain the method of Thread class with example?

Submitted by: Administrator
In this method of creating thread, we have to extend the Thread class and override the run() method in our class to create a Thread.
We have to create an object of the our class.
Once the object is created then we have to invoke the start() method and it will generate a new thread of execution.

For example

public class MyThread extends Thread{
public void run(){
// code to execute under the thread
}
public static void main(String [] args){
MyThread c = new MyThread();
c.start();
}
}
Submitted by: Administrator

Read Online Java Multi-Threading Job Interview Questions And Answers
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.