All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.frameworkset.thread.RunRejectPolicy Maven / Gradle / Ivy

The newest version!
package org.frameworkset.thread;

import org.frameworkset.thread.ThreadPoolExecutor.CallerRunsPolicy;





/**
 * 
 * 

Title: RunRejectPolicy.java

* *

Description:

* *

Copyright (c) 2009

* *

bboss workgroup

* @Date 2009-9-7 * @author biaoping.yin * @version 1.0 */ public class RunRejectPolicy extends CallerRunsPolicy { public void rejectedExecution(Runnable r, ThreadPoolExecutor e) { if (r instanceof RejectTask) { RejectTask task = (RejectTask) r; if(task.isStopORInterrupted()) return; task.setReject(); task.increamentRejecttimes(); } if (!e.isShutdown()) { long waitTime = 1000; if (r instanceof DelayThread) { DelayThread t_ = (DelayThread) r; try { waitTime = t_.getWaittime(); } catch (ThreadException err) { waitTime = 1000; } } if(waitTime < 0) { waitTime = 1000; } synchronized(r) { try { r.wait(waitTime); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } r.run(); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy