1 /* 2 * Zed Attack Proxy (ZAP) and its related class files. 3 * 4 * ZAP is an HTTP/HTTPS proxy for assessing web application security. 5 * 6 * Copyright 2015 The ZAP Development Team 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 package org.zaproxy.zap.utils; 21 22 import java.util.concurrent.ExecutorService; 23 24 /** 25 * A {@code ExecutorService} that allows to pause and resume. Moreover it allows to listen for 26 * termination of the executor. 27 * 28 * @since 2.4.0 29 * @see ExecutorTerminatedListener 30 * @see #pause() 31 * @see #addExecutorTerminatedListener(ExecutorTerminatedListener) 32 */ 33 public interface PausableExecutorService extends ExecutorService { 34 35 /** 36 * Pauses the executor, so that no new task will be executed until {@code resume()} is called. 37 * 38 * @see #resume() 39 */ pause()40 void pause(); 41 42 /** 43 * Resumes the executor, so that the awaiting tasks are executed. 44 * 45 * <p>The call to this method has no effect if the executor is not paused. 46 * 47 * @see #pause() 48 */ resume()49 void resume(); 50 51 /** 52 * Adds the given {@code listener} to the list of listeners that will be notified when the 53 * executor terminates. 54 * 55 * @param listener the listener for termination 56 * @see #isTerminated() 57 * @see #removeExecutorTerminatedListener(ExecutorTerminatedListener) 58 */ addExecutorTerminatedListener(ExecutorTerminatedListener listener)59 void addExecutorTerminatedListener(ExecutorTerminatedListener listener); 60 61 /** 62 * Removes the given {@code listener} from the list of listeners that are notified when the 63 * executor terminates. 64 * 65 * @param listener the listener for termination 66 * @see #isTerminated() 67 * @see #addExecutorTerminatedListener(ExecutorTerminatedListener) 68 */ removeExecutorTerminatedListener(ExecutorTerminatedListener listener)69 void removeExecutorTerminatedListener(ExecutorTerminatedListener listener); 70 } 71