| ||||
| Copyright 1999 Sams Publishing |
| | ||
| | |
| Constructors |
| | |
| Several constructors are available for creating new Thread instances. Most of them are variations on the main constructor with certain values defaulted. |
| | |
| Thread(ThreadGroup, Runnable, String) |
| | |
| public Thread(ThreadGroup group , Runnable target, String name ) |
| throws SecurityException |
| | |
| Creates a new thread that belongs to group , executes the run() method of target , and is named name . This is the main constructor for Thread that is invoked indirectly by the other constructors. |
| | |
| The new Thread will belong to the ThreadGroup referenced by group . If group is null , the new Thread will belong to the same ThreadGroup as the thread that constructed it ( Thread.currentThread().getThreadGroup() ). A SecurityException is thrown if the thread that invoked the constructor is not permitted by the SecurityManager to add a thread to the specified ThreadGroup . |
| | |
| When the thread is started, the run() method of the Runnable referenced by target will be invoked. When run() returns, the thread dies. If target is null , the run() method of the Thread itself will be invoked (typically this will have been overridden in a subclass to do something useful). |
| | |
| The thread will be named using name . If name is null , a NullPointerException will be thrown. To automatically generate a name for the thread, use a different constructor. |
| | |
| The new Thread will have the same priority, daemon status, and context class loader as the Thread that creates it. These settings can be changed with setPriority() , setDaemon() , and setContextClassLoader() . See Chapter 3, Creating and Starting a Thread, for more information. |
| | |
| Thread(ThreadGroup, Runnable) |
| | |
| public Thread(ThreadGroup group, Runnable target) |
| throws SecurityException |
| | |
| Equivalent to using the main constructor like this: Thread(group, target, genName) , where genName is an automatically generated name of the form Thread-16 . |
| | |
| Thread(ThreadGroup, String) |
| | |
| public Thread(ThreadGroup group, String name) throws SecurityException |
| | |
| Equivalent to using the main constructor like this: Thread(group, null, name) . |
| | |
| Thread(Runnable, String) |
| | |
| public Thread(Runnable target, String name) |
| | |
| Equivalent to using the main constructor like this: Thread(null, target, name) . |
| | |
| Thread(Runnable) |
| | |
| public Thread(Runnable target) |
| | |
| Equivalent to using the main constructor like this: Thread(null, target, genName) , where genName is an automatically generated name of the form Thread-2 . |
| | |
| Thread(String) |
| | |
| public Thread(String name) |
| | |
| Equivalent to using the main constructor like this: Thread(null, null, name) . |
| | |
| Thread() |
| | |
| public Thread() |
| | |
| Equivalent to using the main constructor like this: Thread(null, null, genName) , where genName is an automatically generated name of the form Thread-25 . |
| | | ||
| Toc | |||