xuxueli před 6 roky
rodič
revize
5eb5a5e660

+ 2 - 4
xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java Zobrazit soubor

@@ -171,7 +171,7 @@ public class JobScheduleHelper {
171 171
 
172 172
                 // align second
173 173
                 try {
174
-                    TimeUnit.MILLISECONDS.sleep(System.currentTimeMillis()%1000 );
174
+                    TimeUnit.MILLISECONDS.sleep(1000 - System.currentTimeMillis()%1000 );
175 175
                 } catch (InterruptedException e) {
176 176
                     if (!toStop) {
177 177
                         logger.error(e.getMessage(), e);
@@ -181,7 +181,6 @@ public class JobScheduleHelper {
181 181
                 int lastSecond = -1;
182 182
                 while (!toStop) {
183 183
 
184
-                    long start = System.currentTimeMillis();
185 184
                     try {
186 185
                         // second data
187 186
                         List<Integer> ringItemData = new ArrayList<>();
@@ -219,11 +218,10 @@ public class JobScheduleHelper {
219 218
                             logger.error(">>>>>>>>>>> xxl-job, JobScheduleHelper#ringThread error:{}", e);
220 219
                         }
221 220
                     }
222
-                    long cost = System.currentTimeMillis() - start;
223 221
 
224 222
                     // next second, align second
225 223
                     try {
226
-                        TimeUnit.MILLISECONDS.sleep(1000-cost);
224
+                        TimeUnit.MILLISECONDS.sleep(1000 - System.currentTimeMillis()%1000);
227 225
                     } catch (InterruptedException e) {
228 226
                         if (!toStop) {
229 227
                             logger.error(e.getMessage(), e);