What is the target object in java thread?  | | i'm learning java Thread nowdays,and now i met some questions,such as the target object,i can't understand it well,is there any programmer can explain for me in detial?Thanks!
| |
| |
| | | | | | | | | 1. luxram2330 (65) | 3 years ago | An Object that wants to serve as the target of a Thread can declare that it has an appropriate executable method by implementing the java.lang.Runnable interface. Runnable defines a single, general-purpose method:
public interface Runnable{ abstract public void run(); }
Every thread begins its life by executing a run() method in a particular object. run() is a rather mundane method that can hold an arbitrary body of code. It is public, takes no arguments, has no return value, and is not allowed to throw any exceptions.
Any class can contain an appropriate run() method, simply by declaring that it implements the Runnable interface. An instance of this class is then a runnable object that can serve as the target of a new thread. In this way, we can effectively run a method in any object we want.
| |
| |
|
| | Call Java from Uniface Applications Using UD5/JNI you can call Java and EJB methods from Uniface. march-hare.com | add comment |
|
| | | | | |
| Back in Action Spinecare & Rehab Chiropractic - Spinal Decompression - Rehabilitation - Nutrition. www.virginiachiro.com | |
|
|
|
|
|