Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Java Programming Language Interviews:Advanced JavaCore JavaEclipseFull Stack Developer (Java)HibernateIBM WebSphereInternationalization LocalizationJ2EEJ2MEJ2SEJavaJava ANTJava AppletJava BeansJava ClassesJava EJB ProgrammingJava Game DeveloperJava GUI FrameworkJava JNDIJava JNIJava JSP ProgrammingJava Message Service (JMS)Java Multi-ThreadingJava Networking - Sockets and RMIJava PatternsJava SecurityJava Server FacesJava Servlet ProgrammingJava Software EngineerJava Swing ProgrammingJava TechnicalJava ThreadsJava Transaction APIJava Web ServicesJavaMailJBossJDBCJMSJSFPortal and PortletRMISpring FrameworkSr.Java Web DeveloperStrutsSunOneSwing AWTSWT JFace
Copyright © 2018. All Rights Reserved
Java Multi-Threading Interview Question:
Explain the method of Runnable interface with example?
Submitted by: AdministratorIn 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();
}
}
Submitted by: Administrator
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();
}
}
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.