所有
wkwukong · 共 8 篇文章
解决GC问题
1、top查看CPU占用最高的PID 2、ps -mp 9825 -o THREAD,tid,time | sort -rn 9925是步骤1通过top命令查看到得PID 3、printf "%x\n" 9929 4、jstack 9825|grep 26c9 -A 100
2015-08-16 15:08 · JAVA技术 · 评论(0)
Guava event bus 简单例子
最近项目中用到了GUAVA的eventbus来做异步操作,感觉很顺手,这里写了个小demo,作为备忘:(引入guava 18.0版本) 1.AppEventBus类:用来注册,执行和卸载事件,内部实例化了一个AsyncEventBus类,用线程池开了四个线程。 2.StringMessageEvent:事件类。 3.StringMessageListener类:监听者,会实例化一个AppEventBus和一个具体业务处理类StringMsgHandler。当监听到StringMessageEvent事件的时候,会执行 带有 @Subscribe 注解的方法。 4.StringMsgHandl…
2015-07-06 23:54 · JAVA技术 · 评论(0)
一种JAVA线程轮训调度算法(转载)
话不多说,直接上代码(本算法转载自“并发编程网 http://ifeve.com”)。 public class CycleAtomicInteger { private final static long PARK_TIME = 1000L * 1000; private AtomicInteger counter = new AtomicInteger(0); private int range; public CycleAtomicInteger(int range) { if (range < 2) throw new IllegalArgumentException(); this…
2015-07-05 20:37 · JAVA技术 · 评论(0)
JS网页跳转
window.location.href 进行网页跳转,如果带前缀http://(如http://www.baidu.com) , 则跳转到新的网页。如果不带前缀,则当成子路径进行跳转。 window.location.href = "http://www.baidu.com" :跳转到百度的页面 window.location.href = "www.baidu.com" :跳转到 当前路径/www.baidu.com ,结果是找不到网页
JDK默认的三种路径
代码: public class JVMTest { public static void main(String[] args) { String bootPath = System.getProperty("sun.boot.class.path"); String extPath = System.getProperty("java.ext.dirs"); String userPath = System.getProperty("user.dir"); System.out.println(bootPath); System.out.println(extPath); System.…
2013-08-19 10:27 · JAVA技术 · 评论(0)
整数1到N的全排列----非递归方法
庞果网上的一道题目:打印N个字符的全排列,百度了一下。百度百科介绍如下(http://baike.baidu.com/view/1710135.htm),根据百度百科的提示,自己实现了一下,以下为源代码: public class Combine { public static void combine(Integer[] array) { Integer[] res = array; output(array); int flag; while (isDes(res)) { for (int i = res.length - 1; i > 0; i--) { if (res[i - 1] …
2013-03-10 16:27 · 数据结构与算法 · 评论(0)
多叉树的查找及转换
方法一: 1. 带有父节点信息的节点: public class FlatNode { private Integer path; private String name; private Integer parent; public Integer getPath() { return path; } public void setPath(Integer path) { this.path = path; } public Integer getParent() { return parent; } public void setParent(Integer parent) { this…
2013-02-24 15:49 · 数据结构与算法 · 评论(0)