⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 watchthread.java

📁 移动CMPP的网关,JAVA又一实现,非常完整的代码.
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   WatchThread.java

package com.grail.util;

import java.lang.Thread.State;


public abstract class WatchThread extends Thread
{

    private boolean alive;
    private State state;
//    private String state;
    public static final ThreadGroup tg = new ThreadGroup("watch-thread");

    public WatchThread(String name)
    {
        super(tg, name);
        alive = true;
        
        
//        state = "unknown";       
        setDaemon(false);
    }

    public void kill()
    {	
    	System.out.println("jinru close thread");
        alive = false;
    }

    public final void run()
    {	
        while(alive){
        	System.out.println("-------- 线程启动------------");
            try
            {
                task();
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }
            catch(Throwable t)
            {
                t.printStackTrace();
            }
        }
    }

    protected void setState(State newState)
    {
        state = newState;
    }
//    protected void setState(String newState)
//    {
//        state = newState;
//    }
    public State getState()
    {
        return state;
    }
//    public String getState()
//    {
//        return state;
//    }
    protected abstract void task();

}

⌨️ 快捷键说明

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