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


Java Stock类代码示例

本文整理汇总了Java中async.Stockticker.Stock的典型用法代码示例。如果您正苦于以下问题:Java Stock类的具体用法?Java Stock怎么用?Java Stock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: writeStock

import async.Stockticker.Stock; //导入依赖的package包/类
public void writeStock(AsyncContext actx, Stock stock) {
    HttpServletResponse response = (HttpServletResponse)actx.getResponse();
    try {
        PrintWriter writer = response.getWriter();
        writer.write("STOCK#");//make client parsing easier
        writer.write(stock.getSymbol());
        writer.write("#");
        writer.write(stock.getValueAsString());
        writer.write("#");
        writer.write(stock.getLastChangeAsString());
        writer.write("#");
        writer.write(String.valueOf(stock.getCnt()));
        writer.write("\n");
        writer.flush();
        response.flushBuffer();
    }catch (IOException x) {
        try {actx.complete();}catch (Exception ignore){/* Ignore */}
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:20,代码来源:AsyncStockServlet.java

示例2: tick

import async.Stockticker.Stock; //导入依赖的package包/类
@Override
public void tick(Stock stock) {
    ticks.add((Stock)stock.clone());
    Iterator<AsyncContext> it = clients.iterator();
    while (it.hasNext()) {
        AsyncContext actx = it.next();
        try {
            writeStock(actx, stock);
        } catch (Exception e) {
            // Ignore. The async error handling will deal with this.
        }
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:14,代码来源:AsyncStockServlet.java

示例3: tick

import async.Stockticker.Stock; //导入依赖的package包/类
@Override
public void tick(Stock stock) {
    ticks.add((Stock)stock.clone());
    Iterator<AsyncContext> it = clients.iterator();
    while (it.hasNext()) {
        AsyncContext actx = it.next();
        writeStock(actx, stock);
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:AsyncStockServlet.java


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