diggbag

          BlogJava 聯(lián)系 聚合 管理
            0 Posts :: 13 Stories :: 6 Comments :: 0 Trackbacks

          以下方法在centOS下執(zhí)行通過:
          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個結(jié)果就是此進程中有問題的線程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就是線程的編碼,只不過是經(jīng)過了16進制的轉(zhuǎn)換。

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

          posted on 2012-08-01 17:22 哲同 閱讀(3717) 評論(0)  編輯  收藏 所屬分類: java相關(guān)
          主站蜘蛛池模板: 文山县| 肇州县| 白城市| 淮北市| 南昌市| 黄陵县| 镇康县| 东港市| 曲阜市| 建水县| 怀仁县| 微山县| 武汉市| 全州县| 荆州市| 西峡县| 南昌市| 时尚| 合作市| 湾仔区| 布尔津县| 读书| 仁寿县| 平果县| 利辛县| 万年县| 宽城| 临沂市| 台中市| 新余市| 嘉黎县| 丹阳市| 江孜县| 天津市| 通州市| 四会市| 靖边县| 平利县| 苏尼特右旗| 乐至县| 九寨沟县|