mbaen timer=减少数据库调用 -凯发k8官方网
凯发k8官方网
收集整理的这篇文章主要介绍了
mbaen timer=减少数据库调用
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
凯发k8官方网的版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/inforstack/article/details/54250510 datamap = new concurrenthashmap();public static concurrenthashmap getdatamap() {return datamap;}@overridepublic void getdatacount() {timer timer = new timer();timer.schedule(new timertask() {@overridepublic void run() {//每隔4小时更新map中的数据}}, 1000, 14400000);}
}
定义所需接口
public interface homedatambean {public void getdatacount();}实现接口
public class homedata implements homedatambean {private static concurrenthashmap初始化
try {homedata homedata = new homedata();mbeanserver mbs = managementfactory.getplatformmbeanserver();objectname name = new objectname("com.inforstack.clinicalsense.jmx:type=homedata");mbs.registermbean(homedata, name);// objectname, 调用getdatacount,,调用方法所需参数,参数类型//我写的是无参方法所以传递两个nullmbs.invoke(name, "getdatacount", null, null); } catch (exception e) {e.printstacktrace(); }终端命令
jconsole总结
以上是凯发k8官方网为你收集整理的mbaen timer=减少数据库调用的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇:
- 下一篇: express4.x中的链式路由句柄