diggbag

          BlogJava 聯系 聚合 管理
            0 Posts :: 13 Stories :: 6 Comments :: 0 Trackbacks

          以下方法在centOS下執行通過:
          1.先定位占用cpu高的進程

          top

          2.使用以下命令

          ps p 14766 -L -o pcpu,pid,tid,time,tname,stat,psr | sort -n -k1 -r

          其中14766是剛才1中cpu占用率高的進程pid

          3.2.4 32525 32537 01:58:41 ?        Sl     6
          0.8 32525  1771 00:43:12 ?        Sl     0
          0.8 32525  1769 00:39:46 ?        Sl     0
          0.7 32525 12324 00:33:36 ?        Sl     0
          0.5 32525  1772 00:27:50 ?        Sl     0
          0.5 32525  1768 00:25:45 ?        Sl     0
          0.4 32525 30760 00:19:13 ?        Sl     0
          0.4 32525  1773 00:22:36 ?        Sl     0
          0.4 32525  1770 00:20:25 ?        Sl     0
          0.3 32525 32385 00:00:10 ?        Sl     0
          0.1 32525 31668 00:00:03 ?        Sl     0
          0.1 32525 31667 00:00:03 ?        Sl     0
          0.1 32525  1790 00:07:10 ?        Sl     1

           

          其中第3個結果就是此進程中有問題的線程nid

          4.通過jstack命令dump出堆棧

          "AppController_ThreadPool_L2_Pool Thread" daemon prio=10 tid=0x0000000051c2b000 nid=0x7bb3 in Object.wait() [0x000000005e3c5000]
             java.lang.Thread.State: TIMED_WAITING (on object monitor)
                  at java.lang.Object.wait(Native Method)
                  at org.company.threadpool.ThreadPoolImpl$PoolThread.run(ThreadPoolImpl.java:142)
                  - locked <0x00002aaca30341a8> (a org.company.threadpool.ThreadPoolImpl$PoolThread)

          其中的nid就是線程的編碼,只不過是經過了16進制的轉換。

          即十進制的31776對應的十六進制)0x7bb3,定位到線程后一切好辦。 

          posted on 2012-08-01 17:22 哲同 閱讀(3713) 評論(0)  編輯  收藏 所屬分類: java相關
          主站蜘蛛池模板: 五寨县| 文登市| 曲水县| 台北县| 镶黄旗| 巫溪县| 泰州市| 莱西市| 惠东县| 宽城| 清徐县| 福安市| 凉城县| 桦川县| 淅川县| 阜南县| 虎林市| 石嘴山市| 临沭县| 平泉县| 贡觉县| 尉氏县| 体育| 修文县| 团风县| 牡丹江市| 元谋县| 浮梁县| 仁布县| 广宗县| 西林县| 友谊县| 千阳县| 黄大仙区| 峨边| 循化| 章丘市| 平果县| 会泽县| 永川市| 蓬溪县|