Skip to content

Commit 273fb91

Browse files
committed
support: set count 0 to show all threads
1 parent 943689c commit 273fb91

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

bin/show-busy-java-threads

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Output control:
102102
the specified java process.
103103
default from all java process.
104104
-c, --count <num> set the thread count to show, default is 5.
105+
set count 0 to show all threads.
105106
-a, --append-file <file> specifies the file to append output as log.
106107
-S, --store-dir <dir> specifies the directory for storing
107108
the intermediate files, and keep files.
@@ -306,7 +307,11 @@ findBusyJavaThreadsByPs() {
306307
echo "$ps_out" | logAndCat "${ps_cmd_line[@]}" > "${store_file_prefix}$(( i + 1 ))_ps"
307308
fi
308309

309-
echo "$ps_out" | head -n "${count}"
310+
if (( count > 0 )); then
311+
echo "$ps_out" | head -n "${count}"
312+
else
313+
echo "$ps_out"
314+
fi
310315
}
311316

312317
# top with output field: thread id, %cpu
@@ -355,7 +360,7 @@ __complete_pid_user_by_ps() {
355360

356361
local idx=0 threadId pcpu
357362
while read threadId pcpu ; do
358-
(( idx < count )) || break
363+
(( count <= 0 || idx < count )) || break
359364

360365
# output field: pid, threadId, pcpu, user
361366
local output_fields="$( echo "$ps_out" |

docs/java.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ Output control:
124124
the specified java process.
125125
default from all java process.
126126
-c, --count <num> set the thread count to show, default is 5.
127+
set count 0 to show all threads.
127128
-a, --append-file <file> specifies the file to append output as log.
128129
-S, --store-dir <dir> specifies the directory for storing
129130
the intermediate files, and keep files.

0 commit comments

Comments
 (0)