Can a thread be a member of another thread?

Answer Posted / s.ramesh

import java.util.*;

public class DemoThread extends Thread {

private Thread t = null;

public DemoThread() {
t= new Thread(this, "RacingThread");
t.start();
}

public static void main(String[] args) {
DemoThread dt = new DemoThread();
dt.setName("DemoThread");
dt.start();
}
public void run()
{
while(true)
{
try
{
this.sleep(5000);
}
catch(Exception e)
{
System.out.println("Exception Occured");
}
}
}
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is ioc concept?

685


What are JTA/JTS and how they used by client?

1712


how to make a index.jsp for running the site in internet and find an error for connection with weblogic server and java that give an error invalid object name.and how to maintain session.

1746


How would you create a button with rounded edges?

553


Have you used threads in Servelet?

1928






Which textcomponent method is used to set a textcomponent to the read-only state?

625


Whats new with the stop(), suspend() and resume() methods in jdk 1.2?

577


What are the benefits of detached objects?

582


What are the different types of exception?

570


What is a modular application?

585


How can I scroll through list of pages like the search results in google?

562


How would you reatach detached objects to a session when the same object has already been loaded into the session?

675


Why are component architectures useful?

568


What is the purpose of the wait(), notify(), and notifyall() methods?

566


What’s jboss cache in short?

588