< prev index next >

src/java.base/share/classes/java/lang/Thread.java

Print this page




1168      * <code>name</code>.
1169      * <p>
1170      * First the <code>checkAccess</code> method of this thread is called
1171      * with no arguments. This may result in throwing a
1172      * <code>SecurityException</code>.
1173      *
1174      * @param      name   the new name for this thread.
1175      * @exception  SecurityException  if the current thread cannot modify this
1176      *               thread.
1177      * @see        #getName
1178      * @see        #checkAccess()
1179      */
1180     public final synchronized void setName(String name) {
1181         checkAccess();
1182         if (name == null) {
1183             throw new NullPointerException("name cannot be null");
1184         }
1185 
1186         this.name = name;
1187         if (threadStatus != 0) {
1188             setNativeName(name);
1189         }
1190     }
1191 
1192     /**
1193      * Returns this thread's name.
1194      *
1195      * @return  this thread's name.
1196      * @see     #setName(String)
1197      */
1198     public final String getName() {
1199         return name;
1200     }
1201 
1202     /**
1203      * Returns the thread group to which this thread belongs.
1204      * This method returns null if this thread has died
1205      * (been stopped).
1206      *
1207      * @return  this thread's thread group.
1208      */


2082     // Hence, the fields are isolated with @Contended.
2083 
2084     /** The current seed for a ThreadLocalRandom */
2085     @jdk.internal.vm.annotation.Contended("tlr")
2086     long threadLocalRandomSeed;
2087 
2088     /** Probe hash value; nonzero if threadLocalRandomSeed initialized */
2089     @jdk.internal.vm.annotation.Contended("tlr")
2090     int threadLocalRandomProbe;
2091 
2092     /** Secondary seed isolated from public ThreadLocalRandom sequence */
2093     @jdk.internal.vm.annotation.Contended("tlr")
2094     int threadLocalRandomSecondarySeed;
2095 
2096     /* Some private helper methods */
2097     private native void setPriority0(int newPriority);
2098     private native void stop0(Object o);
2099     private native void suspend0();
2100     private native void resume0();
2101     private native void interrupt0();
2102     private native void setNativeName(String name);
2103 }


1168      * <code>name</code>.
1169      * <p>
1170      * First the <code>checkAccess</code> method of this thread is called
1171      * with no arguments. This may result in throwing a
1172      * <code>SecurityException</code>.
1173      *
1174      * @param      name   the new name for this thread.
1175      * @exception  SecurityException  if the current thread cannot modify this
1176      *               thread.
1177      * @see        #getName
1178      * @see        #checkAccess()
1179      */
1180     public final synchronized void setName(String name) {
1181         checkAccess();
1182         if (name == null) {
1183             throw new NullPointerException("name cannot be null");
1184         }
1185 
1186         this.name = name;
1187         if (threadStatus != 0) {
1188             setNativeName(name, false);
1189         }
1190     }
1191 
1192     /**
1193      * Returns this thread's name.
1194      *
1195      * @return  this thread's name.
1196      * @see     #setName(String)
1197      */
1198     public final String getName() {
1199         return name;
1200     }
1201 
1202     /**
1203      * Returns the thread group to which this thread belongs.
1204      * This method returns null if this thread has died
1205      * (been stopped).
1206      *
1207      * @return  this thread's thread group.
1208      */


2082     // Hence, the fields are isolated with @Contended.
2083 
2084     /** The current seed for a ThreadLocalRandom */
2085     @jdk.internal.vm.annotation.Contended("tlr")
2086     long threadLocalRandomSeed;
2087 
2088     /** Probe hash value; nonzero if threadLocalRandomSeed initialized */
2089     @jdk.internal.vm.annotation.Contended("tlr")
2090     int threadLocalRandomProbe;
2091 
2092     /** Secondary seed isolated from public ThreadLocalRandom sequence */
2093     @jdk.internal.vm.annotation.Contended("tlr")
2094     int threadLocalRandomSecondarySeed;
2095 
2096     /* Some private helper methods */
2097     private native void setPriority0(int newPriority);
2098     private native void stop0(Object o);
2099     private native void suspend0();
2100     private native void resume0();
2101     private native void interrupt0();
2102     private native void setNativeName(String name, boolean allowAttachedThread);
2103 }
< prev index next >