future.java

来自「银行项目为后台socket通信写的程序」· Java 代码 · 共 75 行

JAVA
75
字号
/****************************************************************************
 * Package		: com.ecSolutions.ecAppServer.server
 * File			: Future.java
 * Create Date  : 2007-7-20
 * Author		: Steven Chen
 * 
 * Copyright(C) 2006 ecSolutions(shanghai) Co.,Limited.All Rights Reserved.
 *			
 ***************************************************************************/
package com.ecSolutions.ecAppServer.server;

/**
 * A Future represents the result of an asynchronous task.
 * 
 * @author Steven Chen
 * @version $Id: Future.java,v 1.2 2007/07/26 04:10:42 stevenchen Exp $
 */
public interface Future {

    /**
     * Get session associated with the future.
     * 
     * @return session
     */
    Session getSession();

    /**
     * Waits if necessary for the task to complete. Warn: Block operate may lead
     * to artificially low throughput.
     * 
     * @return is succeeded
     */
    boolean complete();

    /**
     * Waits if necessary for the task to complete or the timeout period has
     * expired. Warn: Block operate may lead to artificially low throughput.
     * 
     * @param timeout
     *            timeout
     * @return is completed
     */
    boolean complete(int timeout);

    /**
     * Return true if the task completed.
     * 
     * @return is completed
     */
    boolean isCompleted();

    /**
     * Return true if the task completed successful.
     * 
     * @return is succeeded
     */
    boolean isSucceeded();

    /**
     * Add future listener.
     * 
     * @param listener
     *            future listener
     */
    void addListener(FutureListener listener);

    /**
     * Remove future listener.
     * 
     * @param listener
     *            future listener
     */
    void removeListener(FutureListener listener);
}

⌨️ 快捷键说明

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