{"id":28153795,"url":"https://github.com/leogtzr/jthreadparser","last_synced_at":"2025-06-13T05:32:03.066Z","repository":{"id":57570991,"uuid":"102559606","full_name":"leogtzr/jthreadparser","owner":"leogtzr","description":"jthreadparser is a Go library to parse Java Thread Dump files.","archived":false,"fork":false,"pushed_at":"2021-06-01T23:49:30.000Z","size":6630,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-15T06:12:19.694Z","etag":null,"topics":["go","golang","java","jvm","parser","threaddump"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leogtzr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"leogtzr","patreon":"leogtzr","custom":["https://paypal.me/leogtzr"]}},"created_at":"2017-09-06T03:44:10.000Z","updated_at":"2025-01-31T14:09:39.000Z","dependencies_parsed_at":"2022-09-17T05:24:01.332Z","dependency_job_id":null,"html_url":"https://github.com/leogtzr/jthreadparser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leogtzr/jthreadparser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leogtzr%2Fjthreadparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leogtzr%2Fjthreadparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leogtzr%2Fjthreadparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leogtzr%2Fjthreadparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leogtzr","download_url":"https://codeload.github.com/leogtzr/jthreadparser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leogtzr%2Fjthreadparser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259588766,"owners_count":22880847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","java","jvm","parser","threaddump"],"created_at":"2025-05-15T06:12:17.905Z","updated_at":"2025-06-13T05:32:03.015Z","avatar_url":"https://github.com/leogtzr.png","language":"Go","readme":"[![build](https://github.com/leogtzr/jthreadparser/actions/workflows/build.yml/badge.svg)](https://github.com/leogtzr/jthreadparser/actions/workflows/build.yml)\n[![tests](https://github.com/leogtzr/jthreadparser/actions/workflows/tests.yml/badge.svg)](https://github.com/leogtzr/jthreadparser/actions/workflows/tests.yml)\n\n# jthreadparser\n\n**jthreadparser** is a Go library to parse Java Thread Dump files.\n\n# General usage\n\n```go\nthreads, err := jthreadparser.ParseFromFile(os.Args[1])\n\nif err != nil {\n    log.Fatal(err)\n}\n\nfor _, th := range threads {\n    fmt.Println(th.Name)\n    fmt.Println(th.Priority)\n    fmt.Println(th.NativeID)\n    fmt.Println(th.State)\n    fmt.Println(th.StackTrace)\n}\n```\n\n## Donation / Sponsorship ❤️ 👍\n\nThis code was brought to you by [Leo Gutiérrez](https://github.com/leogtzr) in his free time. If you want to thank me and support the development of this project, please make a small donation on [PayPal](https://www.paypal.me/leogtzr). In case you also like my other open source contributions and articles, please consider motivating me by becoming a sponsor/patron on [Patreon](https://www.patreon.com/leogtzr). Thank you! ❤️\n\n\n\n\nAbove code will help you to get this information from a thread dump file:\n\n![threaddumpsample](imgs/threaddumpsimpleusage.png)\n\n#### Output\n\n\u003cpre\u003e\n'Attach Listener' (0x00007f321c001000) (0x5ac6) [RUNNABLE]\n'DestroyJavaVM' (0x00007f32b4012000) (0x5934) [RUNNABLE]\n'scheduling-1' (0x00007f32b556c000) (0x596c) [TIMED_WAITING]\n'http-nio-8080-Acceptor' (0x00007f32b53d7000) (0x596b) [RUNNABLE]\n'http-nio-8080-ClientPoller' (0x00007f32b53f1000) (0x596a) [RUNNABLE]\n\u003c/pre\u003e\n\n\n\n### Synchronizers\n\nTo get information about which threads are waiting on what (synchronizer states) you can use the *SynchronizersByThread()* method:\n\n```go\nthreadDumpFile := \"../../threaddumpsamples/13.0.2.0.txt\"\n\nthreads, err := jthreadparser.ParseFromFile(threadDumpFile)\nif err != nil {\n    panic(err)\n}\n\nsyncs := jthreadparser.SynchronizersByThread(\u0026threads)\nfor thread, threadSyncs := range syncs {\n    fmt.Printf(\"Thread [%s (%s)], synchronizers: %q\\n\", thread.Name, thread.ID, threadSyncs)\n}\n```\n\n![ims](imgs/synchronizers1.png)\n\n#### Output\n\u003cpre\u003e\n...\nThread [\u003cb\u003escheduling-1\u003c/b\u003e (0x00007f494899a800)]\n\t{0x000000060dc31e60 java.lang.Class for com.thdump.calls.CallResult LockedState}\n\t{0x000000060dc31ed8 java.lang.Class for com.thdump.calls.Call9 LockedState}\n\t{0x000000060dc31f48 java.lang.Class for com.thdump.calls.Call8 LockedState}\n\t{0x000000060dc31fb8 java.lang.Class for com.thdump.calls.Call7 LockedState}\n\t{0x000000060dc32028 java.lang.Class for com.thdump.calls.Call6 LockedState}\n\t{\u003cb\u003e0x000000060dc32098\u003c/b\u003e java.lang.Class for com.thdump.calls.Call5 \u003cb\u003eLockedState\u003c/b\u003e}\n...\nThread [\u003cb\u003ehttp-nio-8080-exec-1\u003c/b\u003e (0x00007f4948cd6000)]\n\t{\u003cb\u003e0x000000060dc32098\u003c/b\u003e java.lang.Class for com.thdump.calls.Call5 \u003cb\u003eWaitingToLockState\u003c/b\u003e}\n\t{0x000000062bac2040 java.lang.Class for com.thdump.calls.Call4 LockedState}\n\t{0x000000062babf8a8 java.lang.Class for com.thdump.calls.Call3 LockedState}\n\t{0x000000062babd110 java.lang.Class for com.thdump.calls.Call2 LockedState}\n\t{\u003cb\u003e0x000000062baba978\u003c/b\u003e java.lang.Class for com.thdump.calls.Call1 \u003cb\u003eLockedState\u003c/b\u003e}\n\t{0x000000060dc11ce0 org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper LockedState}\n...\nThread [\u003cb\u003ehttp-nio-8080-exec-2\u003c/b\u003e (0x00007f494983e800)]\n\t{\u003cb\u003e0x000000062baba978\u003c/b\u003e java.lang.Class for com.thdump.calls.Call1 \u003cb\u003eWaitingToLockState\u003c/b\u003e}\n\t{0x000000062bb035b8 org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper LockedState}\n...\n\u003c/pre\u003e\n\n### Reading from stdin\n\nYou can read from standard input with the **ParseFrom(X)**:\n\n```Go\nthreads, err := jthreadparser.ParseFrom(os.Stdin)\n```\n\n```bash\njstack -l PID | go run myprogram.go\n```\n\n\u003cpre\u003e\n\u003c/pre\u003e\n\n### Most Used Methods\n\nYou can check how many threads include a specific Method using the MostUsedMethods() function:\n\n```go\nthreads, err := jthreadparser.ParseFromFile(\"thread_dump.txt\")\n...\n\nmostUsedMethods := jthreadparser.MostUsedMethods(\u0026threads)\nfor javaMethodName, threadCount := range mostUsedMethods {\n    fmt.Printf(\"%d thread(s) having '%s'\\n\", threadCount, javaMethodName)\n}\n```\n\nOutput:\n```\n...\n241 thread(s) having 'java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)'\n233 thread(s) having 'java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)'\n59 thread(s) having 'java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)'\n...\n```\n\n### Threads with same stacktrace\n\n```go\nthreads, err := jthreadparser.ParseFromFile(\"thread_dump.txt\")\n...\nindenticalStackTrace := jthreadparser.IdenticalStackTrace(\u0026threads)\n\nfor stackTrace, threadCount := range indenticalStackTrace {\n    fmt.Printf(\"%d threads having this stacktrace: \\n\", threadCount)\n    fmt.Println(stackTrace)\n}\n```\n\nOutput:\n```\n...\n20 threads having this stacktrace: \nat sun.misc.Unsafe.park(Native Method)\n- parking to wait for  \u003c0x000000074efc2310\u003e (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)\nat java.util.concurrent.locks.LockSupport.park(LockSupport.java:156)\nat java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)\nat java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:399)\nat java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:957)\nat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:917)\nat java.lang.Thread.run(Thread.java:682)\n1 threads having this stacktrace: \nat java.lang.Object.wait(Native Method)\n- waiting on \u003c0x000000075c8e5d40\u003e (a atg.service.datacollection.DataCollectorQueue)\nat java.lang.Object.wait(Object.java:485)\nat atg.service.queue.EventQueue.getElement(EventQueue.java:236)\n- locked \u003c0x000000075c8e5d40\u003e (a atg.service.datacollection.DataCollectorQueue)\nat atg.service.queue.EventQueue.dispatchQueueElements(EventQueue.java:285)\nat atg.service.queue.EventQueue$Handler.run(EventQueue.java:91)\n1 threads having this stacktrace: \nat java.lang.Object.wait(Native Method)\n...\n```\n","funding_links":["https://github.com/sponsors/leogtzr","https://patreon.com/leogtzr","https://paypal.me/leogtzr","https://www.paypal.me/leogtzr","https://www.patreon.com/leogtzr"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleogtzr%2Fjthreadparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleogtzr%2Fjthreadparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleogtzr%2Fjthreadparser/lists"}