

public Thread() {
init(null, null, "Thread-" + nextThreadNum(), 0);
     }
 String name,
                       long stackSize) {
Thread parent = currentThread();
SecurityManager security = System.getSecurityManager();
if (g == null) {
   /* Determine if it's an applet or not */
   
   /* If there is a security manager, ask the security manager
      what to do. */
   if (security != null) {
g = security.getThreadGroup();
   }
   /* If the security doesn't have a strong opinion of the matter
      use the parent thread group. */
   if (g == null) {
g = parent.getThreadGroup();
   }
}
/* checkAccess regardless of whether or not threadgroup is
            explicitly passed in. */
g.checkAccess();
/*
* Do we have the required permissions?
*/
if (security != null) {
   if (isCCLOverridden(getClass())) {
       security.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
   }
}
         g.addUnstarted();
this.group = g;
this.daemon = parent.isDaemon();
this.priority = parent.getPriority();
this.name = name.toCharArray();
if (security == null || isCCLOverridden(parent.getClass()))
   this.contextClassLoader = parent.getContextClassLoader();
else
   this.contextClassLoader = parent.contextClassLoader;
this.inheritedAccessControlContext = AccessController.getContext();
this.target = target;
setPriority(priority);
         if (parent.inheritableThreadLocals != null)
   this.inheritableThreadLocals =
ThreadLocal.createInheritedMap(parent.inheritableThreadLocals);
         /* Stash the specified stack size in case the VM cares */
         this.stackSize = stackSize;
         /* Set thread ID */
         tid = nextThreadID();
     }
 public final String getName() {
return String.valueOf(name);
     }//********************************************************************************
也可以指定名字:
package com.ygl;
 public class ThreadTest {
      public static void main(String[] args) {
     Thread t1=new Thread1("Thread1");
     t1.start();
     Thread t2=new Thread1("Thread2");
     t1.start();
}
      
 }
 class Thread1 extends Thread{
public Thread1(String name){
super(name);
}
@Override
public void run() {
for(int i=0;i<100;i++){
System.out.println("Thread1"+i);
}
}
 }
 class Thread2 extends Thread{
public Thread2(String name){    
super(name);   //  public Thread(String name) {init(null, null, name, 0);}
}
@Override
public void run() {
for(int i=0;i<100;i++){
System.out.println("Thread2"+i);
}
}
 }