suspender.java~1~
来自「封装了SQL、Socket、WAP、MIME等功能的通用组件」· JAVA~1~ 代码 · 共 63 行
JAVA~1~
63 行
package com.lazybug.util;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: www.lazybug.com Copyright (c) 2004</p>
* <p>Company: www.lazybug.com</p>
* @author 刘学
* @version 0.5
*/
public class Suspender
{
private int count = 0;
private int timeout = 100; //默认暂停100毫秒
private int interrupt = 1024; //中断次数
private Thread thread = null;
public Suspender(Thread p0)
{
this.thread = p0;
}
/**
*
* @param p0 要中断的线程
* @param p1 执行中断的次数
*/
public Suspender(Thread p0, int p1)
{
this(p0);
this.interrupt = p1;
}
/**
*
* @param p0 要中断的线程
* @param p1 执行中断的次数
* @param p2 终端的时间
*/
public Suspender(Thread p0, int p1, int p2)
{
this(p0);
this.interrupt = p1;
this.timeout = p2;
}
public final void suspend()
{
count += 1;
if( count > interrupt )
{
try
{
thread.sleep(timeout);
}
catch(InterruptedException e)
{
}
count = 0;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?