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

📄 mworkerthread.java

📁 httptunnel.jar httptunnel java 源码
💻 JAVA
字号:
package net.jumperz.util;

public final class MWorkerThread
extends Thread
{
private MCommand command;
private boolean suspended;
private volatile boolean terminated;
private MThreadPool threadPool;
//--------------------------------------------------------------------
public MWorkerThread( MThreadPool in_threadPool )
{
threadPool	= in_threadPool;
terminated	= false;
suspended	= true;
start();
}
//--------------------------------------------------------------------
public final void run()
{
while( !terminated )
	{
	synchronized( this )
		{
		while( suspended )
			{
			try
				{
				wait();
				}
			catch( Exception e )
				{
				e.printStackTrace();
				//break;
				}
			}
		}
	
	if( terminated )
		{
		break;
		}

	try
		{
		command.execute();
		}
	catch( Throwable e )
		{
		 // execute() throws no Exception
		System.err.println( "########## Caught a Throwable #########" );
		e.printStackTrace();
		command.breakCommand();	
		}

	command = null;
	suspended = true;
	threadPool.setThreadWait( this );
	}
}
//--------------------------------------------------------------------
public final void setCommand( MCommand in_Command )
{
command = in_Command;
}
//--------------------------------------------------------------------
public final void terminate()
{
terminated = true;
}
//--------------------------------------------------------------------
public final synchronized void resumeThread()
{
suspended = false;
notify();
}
//--------------------------------------------------------------------
public final void breakThread()
{
if( command != null )
	{
	command.breakCommand();
	}
}
//--------------------------------------------------------------------
}

⌨️ 快捷键说明

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