MCPcopy
hub / github.com/vipshop/vjtools / run

Method run

vjtop/src/main/java/com/vip/vjtools/vjtop/VJTop.java:129–164  ·  view source on GitHub ↗
(VMDetailView view)

Source from the content-addressed store, hash-verified

127 }
128
129 private void run(VMDetailView view) throws Exception {
130 try {
131 // System.out 设为Buffered,需要使用System.out.flush刷新
132 System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out)), false));
133
134 int iterations = 0;
135 while (!view.shouldExit()) {
136 waitForInput();
137 view.printView();
138 if (view.shouldExit()) {
139 break;
140 }
141
142 System.out.flush();
143
144 if (maxIterations > 0 && iterations >= maxIterations) {
145 break;
146 }
147
148 // 第一次最多只等待3秒
149 int sleepSeconds = (iterations == 0) ? Math.min(3, interval) : interval;
150
151 iterations++;
152 sleepStartTime = System.currentTimeMillis();
153 Utils.sleep(sleepSeconds * 1000L);
154 }
155 System.out.println("");
156 System.out.flush();
157 } catch (NoClassDefFoundError e) {
158 e.printStackTrace(System.out);
159 System.out.println(Formats.red("ERROR: Some JDK classes cannot be found."));
160 System.out.println(" Please check if the JAVA_HOME environment variable has been set to a JDK path.");
161 System.out.println("");
162 System.out.flush();
163 }
164 }
165
166 public static void printHelper(OptionParser parser) {
167 try {

Callers 1

mainMethod · 0.95

Calls 8

waitForInputMethod · 0.95
sleepMethod · 0.95
redMethod · 0.95
shouldExitMethod · 0.80
printViewMethod · 0.80
minMethod · 0.80
flushMethod · 0.65
currentTimeMillisMethod · 0.65

Tested by

no test coverage detected