Top


定義場所(file name)

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

説明(description)

    /**
     * Changes the priority of this thread.
     * <p>
     * First the <code>checkAccess</code> method of this thread is called
     * with no arguments. This may result in throwing a
     * <code>SecurityException</code>.
     * <p>
     * Otherwise, the priority of this thread is set to the smaller of
     * the specified <code>newPriority</code> and the maximum permitted
     * priority of the thread's thread group.
     *
     * @param newPriority priority to set this thread to
     * @exception  IllegalArgumentException  If the priority is not in the
     *               range <code>MIN_PRIORITY</code> to
     *               <code>MAX_PRIORITY</code>.
     * @exception  SecurityException  if the current thread cannot modify
     *               this thread.
     * @see        #getPriority
     * @see        #checkAccess()
     * @see        #getThreadGroup()
     * @see        #MAX_PRIORITY
     * @see        #MIN_PRIORITY
     * @see        ThreadGroup#getMaxPriority()
     */

名前(function name)

    public final void setPriority(int newPriority) {

本体部(body)

  {- -------------------------------------------
  (1) (変数宣言など)
      ---------------------------------------- -}

            ThreadGroup g;

  {- -------------------------------------------
  (1) 
      ---------------------------------------- -}

            checkAccess();

  {- -------------------------------------------
  (1) 引数で指定された新しい優先度(newPriority)が, 値として指定できる範囲を超えていたら 
      IllegalArgumentException.
      ---------------------------------------- -}

            if (newPriority > MAX_PRIORITY || newPriority < MIN_PRIORITY) {
                throw new IllegalArgumentException();
            }

  {- -------------------------------------------
  (1) java.lang.Thread.setPriority0() を呼び出して, 優先度を設定する.
      (なお, 指定された新しい優先度(newPriority)が所属する ThreadGroup の最大優先度を超えていたら, そこまで切り詰めておく)
      ---------------------------------------- -}

            if((g = getThreadGroup()) != null) {
                if (newPriority > g.getMaxPriority()) {
                    newPriority = g.getMaxPriority();
                }
                setPriority0(priority = newPriority);
            }
        }

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.