Class Overview | Class Members | This Package | All Packages
Threads created this way must have overridden their run() method to actually do anything. An example illustrating this method being used follows:
import java.lang.*; class plain01 implements Runnable { String name; plain01() { name = null; } plain01(String s) { name = s; } public void run() { if (name == null) System.out.println("A new thread created"); else System.out.println("A new thread with name " + name + " created"); } } class threadtest01 { public static void main(String args[] ) { int failed = 0 ; Thread t1 = new Thread(); if (t1 != null) System.out.println("new Thread() succeed"); else { System.out.println("new Thread() failed"); failed++; } } }
If group is not null, the checkAccess method of that thread group is called with no arguments; this may result in throwing a SecurityException; if group is null, the new process belongs to the same group as the thread that is creating the new thread.
If the target argument is not null, the run method of the target is called when this thread is started. If the target argument is null, this thread's run method is called when this thread is started.
The priority of the newly created thread is set equal to the priority of the thread creating it, that is, the currently running thread. The method setPriority may be used to change the priority to a new value.
The newly created thread is initially marked as being a daemon thread if and only if the thread creating it is currently marked as a daemon thread. The method setDaemon may be used to change whether or not a thread is a daemon.