/*
* 创建日期 2005-12-7
*/
package cn.com.skyon.sms.awork;
import org.apache.log4j.Logger;
import cn.com.skyon.sms.Other.DataContainer;
/**
* 线程池中的执行者
* @author ghl
*/
public class Peon implements Runnable
{
private static Logger logger = Logger.getLogger(Peon.class);
private DataContainer container = DataContainer.getInstance();
public void run()
{
while(!Thread.currentThread().isInterrupted())
{
try
{
Runnable runnable ;
synchronized (container)
{
try
{
while (container.executorSize() == 0 && !Thread.currentThread().isInterrupted())
{
try
{
container.wait();
}
catch (InterruptedException e)
{
}
}
runnable = container.popExecutor();
}
finally
{
container.notifyAll();
}
}
if (runnable != null)
{
logger.info("成功获得执行器,开始执行……");
runnable.run();
logger.info("执行完毕");
}
}
catch (Exception e)
{
logger.error("执行期间出现错误",e);
}
}
logger.info("执行线程结束");
}
}