当前位置: 首页>>代码示例>>Java>>正文


Java Window.destroy方法代码示例

本文整理汇总了Java中com.cloudhopper.commons.util.windowing.Window.destroy方法的典型用法代码示例。如果您正苦于以下问题:Java Window.destroy方法的具体用法?Java Window.destroy怎么用?Java Window.destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.cloudhopper.commons.util.windowing.Window的用法示例。


在下文中一共展示了Window.destroy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.cloudhopper.commons.util.windowing.Window; //导入方法依赖的package包/类
static public void main(String[] args) throws Exception {
    
    ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
    WindowListener listener = new WindowListener<Integer,String,String>() {
        @Override
        public void expired(WindowFuture<Integer, String, String> entry) {
            logger.debug("The key=" + entry.getKey() + ", request=" + entry.getRequest() + " expired");
        }
    };
    
    Window<Integer,String,String> window = new Window<Integer,String,String>(2, executor, 5000, listener);
    Window<Integer,String,String> window2 = new Window<Integer,String,String>(2, executor, 5000, listener, "window2monitor");
    
    WindowFuture<Integer,String,String> future0 = window.offer(0, "Request0", 1000, 4000);
    logger.info("Request0 offered at " + future0.getOfferTimestamp() + " and expires at " + future0.getExpireTimestamp());
    //requestFuture.await();

    System.out.println("Press any key to add another request...");
    System.in.read();

    WindowFuture<Integer,String,String> future1 = window2.offer(1, "Request1", 1000, 4000);
    logger.info("Request1 offered at " + future1.getOfferTimestamp() + " and expires at " + future1.getExpireTimestamp());

    System.out.println("Press any key to add response...");
    System.in.read();

    logger.info("Adding Response1...");
    WindowFuture<Integer,String,String> responseFuture1 = window.complete(1, "Response1");
    if (responseFuture1 == null) {
        logger.info("Request1 was not present in window");
    } else {
        logger.info(responseFuture1.getRequest());
        logger.info(responseFuture1.getResponse());
    }

    /**
    // add a response
    ResponseFuture<Integer,String,String> responseFuture0 = requestWindow.addResponse(0, "Response0");
    logger.info(responseFuture0.getRequest());
    logger.info(responseFuture0.getResponse());
    logger.info("Processing Time: " + responseFuture0.getProcessingTime() + " ms");

    // this should timeout dude...
    RequestFuture<Integer,String,String> requestFuture1 = requestWindow.addRequest(1, "Request1", 1000);
    logger.info("Request1 worked");

    ResponseFuture<Integer,String,String> responseFuture1 = requestWindow.addResponse(1, "Response1");
    logger.info(responseFuture1.getRequest());
    logger.info(responseFuture1.getResponse());
    logger.info("Processing Time: " + responseFuture1.getProcessingTime() + " ms");
     */
    
    System.out.println("Press any key to get rid of our reference to Window");
    System.in.read();
    
    window.destroy();
    window2.destroy();
    window = null;
    window2 = null;
    System.gc();
    
    System.out.println("Press any key to exit...");
    System.in.read();
    
    executor.shutdown();
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:67,代码来源:Window2Main.java


注:本文中的com.cloudhopper.commons.util.windowing.Window.destroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。