Example usage for java.util.concurrent RunnableFuture toString

List of usage examples for java.util.concurrent RunnableFuture toString

Introduction

In this page you can find the example usage for java.util.concurrent RunnableFuture toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.mule.service.scheduler.internal.executor.ByCallerThrottlingPolicy.java

public void throttle(Runnable throttledCallback, RunnableFuture<?> task, ThrottledScheduler scheduler) {
    ThreadGroup currentThreadGroup = currentThread().getThreadGroup();

    ++rejectedCount;//from  ww w .  j ava  2  s.  c  o m

    if (!isSchedulerThread(currentThreadGroup) || isWaitGroupThread(currentThreadGroup)) {
        try {
            synchronized (runningTasks) {
                runningTasks.incrementAndGet();
                while (runningTasks.get() > maxConcurrentTasks) {
                    if (isLogThrottleEnabled()) {
                        logThrottle(task.toString(), "WaitPolicy", scheduler.toString());
                    }
                    runningTasks.wait();
                }
            }
            throttledCallback.run();
        } catch (InterruptedException e) {
            currentThread().interrupt();
            throw new MuleRuntimeException(e);
        }
    } else {
        synchronized (runningTasks) {
            if (runningTasks.incrementAndGet() > maxConcurrentTasks) {
                if (isLogThrottleEnabled()) {
                    logThrottle(task.toString(), "AbortPolicy", scheduler.toString());
                }
                throw new SchedulerTaskThrottledException(
                        "Task '" + task.toString() + "' throttled back from '" + scheduler.toString() + "'");
            } else {
                throttledCallback.run();
            }
        }
    }
}