32
32
import sun .nio .ch .Poller ;
33
33
34
34
/**
35
- * The implementation for the jcmd Thread.vthread_* diagnostic commands.
35
+ * The implementation for the jcmd Thread.vthread_* diagnostic commands. These methods are
36
+ * called from the "Attach Listener" thread.
36
37
*/
37
38
public class JcmdVThreadCommands {
38
39
private static final JavaLangAccess JLA = SharedSecrets .getJavaLangAccess ();
@@ -47,22 +48,21 @@ private static byte[] printScheduler() {
47
48
48
49
// virtual thread scheduler
49
50
sb .append (JLA .virtualThreadDefaultScheduler ())
50
- .append (System .lineSeparator ());
51
+ .append (System .lineSeparator ());
51
52
52
53
// break
53
54
sb .append (System .lineSeparator ());
54
55
55
56
// delayed task schedulers
57
+ sb .append ("Delayed task schedulers:" ).append (System .lineSeparator ());
56
58
var delayedTaskSchedulers = JLA .virtualThreadDelayedTaskSchedulers ().toList ();
57
- sb .append ("Delayed task schedulers:" )
58
- .append (System .lineSeparator ());
59
- for (int i = 0 ; i < delayedTaskSchedulers .size (); i ++) {
60
- sb .append ('[' )
61
- .append (i )
62
- .append ("] " )
63
- .append (delayedTaskSchedulers .get (i ))
64
- .append (System .lineSeparator ());
65
- }
59
+ IntStream .range (0 , delayedTaskSchedulers .size ())
60
+ .forEach (i -> sb .append ('[' )
61
+ .append (i )
62
+ .append ("] " )
63
+ .append (delayedTaskSchedulers .get (i ))
64
+ .append (System .lineSeparator ()));
65
+
66
66
return sb .toString ().getBytes (StandardCharsets .UTF_8 );
67
67
}
68
68
@@ -78,30 +78,34 @@ private static byte[] printPollers() {
78
78
79
79
if (masterPoller != null ) {
80
80
sb .append ("Master I/O poller:" )
81
- .append (System .lineSeparator ())
82
- .append (masterPoller )
83
- .append (System .lineSeparator ());
81
+ .append (System .lineSeparator ())
82
+ .append (masterPoller )
83
+ .append (System .lineSeparator ());
84
+
85
+ // break
84
86
sb .append (System .lineSeparator ());
85
87
}
86
88
87
89
sb .append ("Read I/O pollers:" );
88
90
sb .append (System .lineSeparator ());
89
91
IntStream .range (0 , readPollers .size ())
90
92
.forEach (i -> sb .append ('[' )
91
- .append (i )
92
- .append ("] " )
93
- .append (readPollers .get (i ))
94
- .append (System .lineSeparator ()));
93
+ .append (i )
94
+ .append ("] " )
95
+ .append (readPollers .get (i ))
96
+ .append (System .lineSeparator ()));
97
+
98
+ // break
95
99
sb .append (System .lineSeparator ());
96
100
97
101
sb .append ("Write I/O pollers:" );
98
102
sb .append (System .lineSeparator ());
99
103
IntStream .range (0 , writePollers .size ())
100
104
.forEach (i -> sb .append ('[' )
101
- .append (i )
102
- .append ("] " )
103
- .append (writePollers .get (i ))
104
- .append (System .lineSeparator ()));
105
+ .append (i )
106
+ .append ("] " )
107
+ .append (writePollers .get (i ))
108
+ .append (System .lineSeparator ()));
105
109
106
110
return sb .toString ().getBytes (StandardCharsets .UTF_8 );
107
111
}
0 commit comments