首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > Java > 效率不会高的 AbstractBoarHandler
【标  题】:效率不会高的 AbstractBoarHandler
【关键字】:AbstractBoarHandler
【来  源】:http://blog.csdn.net/zhuam/archive/2006/09/07/1188603.aspx

效率不会高的 AbstractBoarHandler

因为 boar application 会维持一个 boarManager ,而 一个boar 会有一个 AbstractBoarHandler ,故而这里

代码这样写会是很消耗资源地 ,你平时写代码有注意这些没 ...

/**
 * Copyright (C) 2006 the original author or authors.
 *
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution.
 */

package com.boar;

import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import com.boar.domain.Instruct;
import com.boar.domain.InstructManager;
import com.boar.domain.impl.DBInstructManager;

/**
 * Abstract Handler 
 *
 * @author <a href="zhuaming@gmail.com">Ben </a>
 *
 */

public abstract class AbstractBoarHandler {
 
 protected InstructManager instructManager = new DBInstructManager();
 protected List<Instruct> instructs = null;
 private String workgroupID ;
 
 public AbstractBoarHandler(String workgroupID) {
  this.workgroupID = workgroupID;
  instructs = instructManager.getInstructs(workgroupID);
  
  ScheduledExecutorService scheduledExecute = Executors.newSingleThreadScheduledExecutor();
  scheduledExecute.scheduleAtFixedRate(new Worker(),1, 120, TimeUnit.SECONDS);
 }

 public abstract String process(String packet);
  
 private class Worker implements Runnable {
  public void run() {
   instructs = instructManager.getInstructs(workgroupID);
  } 
 }
 

在你的企业级java应用中使用Drools:【上一篇】
javascript基础知识:【下一篇】
【相关文章】
没有相关文章
【随机文章】
  • 双机互联双机互连共享上网的解决办法
  • jsp计数器-bean文件
  • 用VC++和Winsock实现与HTTP服务器通话
  • 关于SQL Server 2005 的SSIS临时笔记
  • Photoshop实用技巧:用光晕来美化字体
  • 微软ping程序源代码完整版
  • 论嵌入式Linux的MiniGUI研究和移植[转]
  • 最难搞定的HelloWorld(编译)
  • qemu
  • Get Styles
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.