java singalException

1117 ワード

以前、毕大師の異常な多さによるcpu usに関する高い分析メールを見たと同時に、今日は異常なbenchmarkをした人がいるのを見て、またよくある需要が異常でプログラムを遮断しているのを見た.JAvaで私が知っている限りでは、現在は異常でプログラム実行を遮断するしかなく、他の効率的なプログラム実行を遮断する方法はないので、singal方式のようにプログラム実行を遮断する必要があり、異常として処理するものではない場合は、throwableを再ロードする以下の方法が望ましい.
 
/**
     * Fills in the execution stack trace. This method records within this
     * <code>Throwable</code> object information about the current state of
     * the stack frames for the current thread.
     *
     * @return  a reference to this <code>Throwable</code> instance.
     * @see     java.lang.Throwable#printStackTrace()
     */
    public synchronized native Throwable fillInStackTrace();
public  Throwable fillInStackTrace(){  return this;}

 これにより、この異常がnewされると比較的高いオーバーヘッドは発生しません.私の命名習慣によると、この異常クラスはSingalExceptionと呼ぶべきです.
 
他の人が作ったbenchmarkを添付します
 
Java基本操作性能
https://github.com/wenshao/benchmark/wiki