File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Thread questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Thread questions" Watch "Thread questions" New topic

Thread questions

Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
Thread questions:
Q.1 I don't understand interrupt() and internal flag and when should I use it?
Q.2 What does "No thread can make another thread yield" mean?
Q.3 Given:
public class MyRunnable implements Runnable
public void run()
//some code here
What is the proper way to create and start this thread?
Ans: new Thread(new MyRunnable()).start();
Why does it need to add new Thread as prefix?
Q.4 Given:
public class MyT extends Thread
public void run()
for(int i=1; i<5; i++)<br /> {<br /> System.out.print(i + " ");<br /> if(i>2)
catch(InterruptedException e)
Assume another object creates an instance of this Thread and starts it. Why does the outcome is:
1 2 3 caught
Thanks a lot.
I agree. Here's the link:
subject: Thread questions