史荣久

史荣久的博客

他的个人主页  他的博客

JAVA 多线程性能估算

史荣久  2011年01月13日 星期四 10:10 | 2200次浏览 | 0条评论

就是 1,3,5 质数关系,hoho

大概用了下面的测试方法,20个线程

public A9IC makeSync(){
    synchronized (a9sq) {
        int sq = (int)a9sq.next();
        return new A9IC(layoutType,instanceId,sq);
    }
}

public A9IC makeAsync(){
        int sq = (int)a9sq.next();
        return new A9IC(layoutType,instanceId,sq);
}

结果:

单线程 makeSync()   9704 次/毫秒
20线程 makeSync()   3444 次/毫秒
单线程 makeAsync()  14913 次/毫秒

估算:

假设,非同步方法 性能是 5。那么,
同步方法单线程时,性能估为 3。
同步方法多线程时,性能估为 1。
线程竞争越激烈,性能越差。

就是 1,3,5 质数关系,hoho

提示:
以上只是十分粗略的估算。

更多资料
http://docs.huihoo.com/java/java_performance.html

评论

我的评论:

发表评论

请 登录 后发表评论。还没有在Zeuux哲思注册吗?现在 注册 !

暂时没有评论

Zeuux © 2024

京ICP备05028076号