threadpoolentry.java

来自「network management, thread implement」· Java 代码 · 共 79 行

JAVA
79
字号
// Developed by Kinva Network Inc. 2000


// Source File Name:   ThreadPoolEntry.java

package com.kinva.util.thread;

import java.io.PrintStream;

// Referenced classes of package com.kinva.util.thread:
//            PoolThread, ThreadPool

public class ThreadPoolEntry
{

    ThreadPoolEntry(ThreadPool threadpool, PoolThread poolthread)
    {
        pool = threadpool;
        pt = poolthread;
        state = 0;
    }

    public PoolThread getThread()
    {
        return pt;
    }

    synchronized void waitForRelease()
    {
        while(state != 1) 
            try
            {
                wait();
            }
            catch(InterruptedException interruptedexception)
            {
                System.err.println(interruptedexception);
            }
    }

    public synchronized void release()
    {
        state = 1;
        notify();
    }

    void idle()
    {
        state = 0;
        pool.insertIdle(this);
    }

    void init()
    {
        pt.setPoolEntry(this);
        pt.start();
    }

    synchronized void shutdown()
    {
        if(state == 1)
            pt.abort();
        pt.stop();
    }

    public String toString()
    {
        return pt.toString();
    }

    public static final int TS_IDLE = 0;
    public static final int TS_BUSY = 1;
    private int state;
    private PoolThread pt;
    private ThreadPool pool;
    ThreadPoolEntry next;
    ThreadPoolEntry prev;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?