home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 25 / CDROM25.iso / Share / prog / VJ11 / VJTRIAL.EXE / IE30Java.exe / classd.exe / java / lang / Thread.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-27  |  5.2 KB  |  249 lines

  1. package java.lang;
  2.  
  3. public class Thread implements Runnable {
  4.    private char[] name;
  5.    private int priority;
  6.    private Thread threadQ;
  7.    private int PrivateInfo;
  8.    private int eetop;
  9.    private boolean single_step;
  10.    private boolean daemon = false;
  11.    private boolean stillborn = false;
  12.    private Runnable target;
  13.    private boolean interruptRequested = false;
  14.    private static Thread activeThreadQ;
  15.    private ThreadGroup group;
  16.    private static int threadInitNumber;
  17.    public static final int MIN_PRIORITY = 1;
  18.    public static final int NORM_PRIORITY = 5;
  19.    public static final int MAX_PRIORITY = 10;
  20.  
  21.    private static synchronized int nextThreadNum() {
  22.       return threadInitNumber++;
  23.    }
  24.  
  25.    public static native Thread currentThread();
  26.  
  27.    public static native void yield();
  28.  
  29.    public static native void sleep(long var0) throws InterruptedException;
  30.  
  31.    public static void sleep(long var0, int var2) throws InterruptedException {
  32.       if (var2 > 500000) {
  33.          ++var0;
  34.       }
  35.  
  36.       sleep(var0);
  37.    }
  38.  
  39.    private void init(ThreadGroup var1, Runnable var2, String var3) {
  40.       Thread var4 = currentThread();
  41.       if (var1 == null) {
  42.          var1 = var4.getThreadGroup();
  43.       } else {
  44.          var1.checkAccess();
  45.       }
  46.  
  47.       this.group = var1;
  48.       this.daemon = var4.isDaemon();
  49.       this.priority = var4.getPriority();
  50.       this.name = var3.toCharArray();
  51.       this.target = var2;
  52.       this.setPriority0(this.priority);
  53.       var1.add(this);
  54.    }
  55.  
  56.    public Thread() {
  57.       this.init((ThreadGroup)null, (Runnable)null, "Thread-" + nextThreadNum());
  58.    }
  59.  
  60.    public Thread(Runnable var1) {
  61.       this.init((ThreadGroup)null, var1, "Thread-" + nextThreadNum());
  62.    }
  63.  
  64.    public Thread(ThreadGroup var1, Runnable var2) {
  65.       this.init(var1, var2, "Thread-" + nextThreadNum());
  66.    }
  67.  
  68.    public Thread(String var1) {
  69.       this.init((ThreadGroup)null, (Runnable)null, var1);
  70.    }
  71.  
  72.    public Thread(ThreadGroup var1, String var2) {
  73.       this.init(var1, (Runnable)null, var2);
  74.    }
  75.  
  76.    public Thread(Runnable var1, String var2) {
  77.       this.init((ThreadGroup)null, var1, var2);
  78.    }
  79.  
  80.    public Thread(ThreadGroup var1, Runnable var2, String var3) {
  81.       this.init(var1, var2, var3);
  82.    }
  83.  
  84.    public synchronized native void start();
  85.  
  86.    public void run() {
  87.       if (this.target != null) {
  88.          this.target.run();
  89.       }
  90.  
  91.    }
  92.  
  93.    private void exit() {
  94.       if (this.group != null) {
  95.          this.group.remove(this);
  96.          this.group = null;
  97.       }
  98.  
  99.    }
  100.  
  101.    public final void stop() {
  102.       this.stop(new ThreadDeath());
  103.    }
  104.  
  105.    public final synchronized void stop(Throwable var1) {
  106.       this.checkAccess();
  107.       this.stop0(var1);
  108.    }
  109.  
  110.    public void interrupt() {
  111.       this.interruptRequested = true;
  112.    }
  113.  
  114.    public static boolean interrupted() {
  115.       return currentThread().interruptRequested;
  116.    }
  117.  
  118.    public boolean isInterrupted() {
  119.       return this.interruptRequested;
  120.    }
  121.  
  122.    public void destroy() {
  123.       throw new NoSuchMethodError();
  124.    }
  125.  
  126.    public final native boolean isAlive();
  127.  
  128.    public final void suspend() {
  129.       this.checkAccess();
  130.       this.suspend0();
  131.    }
  132.  
  133.    public final void resume() {
  134.       this.checkAccess();
  135.       this.resume0();
  136.    }
  137.  
  138.    public final void setPriority(int var1) {
  139.       this.checkAccess();
  140.       if (var1 <= 10 && var1 >= 1) {
  141.          if (var1 > this.group.getMaxPriority()) {
  142.             var1 = this.group.getMaxPriority();
  143.          }
  144.  
  145.          this.setPriority0(this.priority = var1);
  146.       } else {
  147.          throw new IllegalArgumentException();
  148.       }
  149.    }
  150.  
  151.    public final int getPriority() {
  152.       return this.priority;
  153.    }
  154.  
  155.    public final void setName(String var1) {
  156.       this.checkAccess();
  157.       this.name = var1.toCharArray();
  158.    }
  159.  
  160.    public final String getName() {
  161.       return String.valueOf(this.name);
  162.    }
  163.  
  164.    public final ThreadGroup getThreadGroup() {
  165.       return this.group;
  166.    }
  167.  
  168.    public static int activeCount() {
  169.       return currentThread().getThreadGroup().activeCount();
  170.    }
  171.  
  172.    public static int enumerate(Thread[] var0) {
  173.       return currentThread().getThreadGroup().enumerate(var0);
  174.    }
  175.  
  176.    public native int countStackFrames();
  177.  
  178.    public final synchronized void join(long var1) throws InterruptedException {
  179.       long var3 = System.currentTimeMillis();
  180.       long var5 = 0L;
  181.       if (var1 == 0L) {
  182.          while(this.isAlive()) {
  183.             this.wait(0L);
  184.          }
  185.  
  186.       } else {
  187.          while(this.isAlive()) {
  188.             long var7 = var1 - var5;
  189.             if (var7 <= 0L) {
  190.                break;
  191.             }
  192.  
  193.             this.wait(var7);
  194.             var5 = System.currentTimeMillis() - var3;
  195.          }
  196.  
  197.       }
  198.    }
  199.  
  200.    public final synchronized void join(long var1, int var3) throws InterruptedException {
  201.       if (var3 >= 500000 || var1 == 0L) {
  202.          ++var1;
  203.       }
  204.  
  205.       this.join(var1);
  206.    }
  207.  
  208.    public final void join() throws InterruptedException {
  209.       this.join(0L);
  210.    }
  211.  
  212.    public static void dumpStack() {
  213.       (new Exception("Stack trace")).printStackTrace();
  214.    }
  215.  
  216.    public final void setDaemon(boolean var1) {
  217.       this.checkAccess();
  218.       if (this.isAlive()) {
  219.          throw new IllegalThreadStateException();
  220.       } else {
  221.          this.daemon = var1;
  222.       }
  223.    }
  224.  
  225.    public final boolean isDaemon() {
  226.       return this.daemon;
  227.    }
  228.  
  229.    public void checkAccess() {
  230.       SecurityManager var1 = System.getSecurityManager();
  231.       if (var1 != null) {
  232.          var1.checkAccess(this);
  233.       }
  234.  
  235.    }
  236.  
  237.    public String toString() {
  238.       return "Thread[" + this.getName() + "," + this.getPriority() + "," + this.getThreadGroup().getName() + "]";
  239.    }
  240.  
  241.    private native void setPriority0(int var1);
  242.  
  243.    private native void stop0(Object var1);
  244.  
  245.    private native void suspend0();
  246.  
  247.    private native void resume0();
  248. }
  249.