Skip to content

Commit

Permalink
修改线程数量
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrric committed Aug 25, 2020
1 parent a88d277 commit bf71471
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/java/com/github/lyrric/service/SecKillService.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public void startSecKill(Integer vaccineId, String startDateStr, MainFrame mainF
if(System.currentTimeMillis() > startDate+1000*30 || success.get()){
return;
}
if("操作过于频繁,请稍后再试!".equals(e.getErrMsg()) && new Random().nextBoolean()){
try {
Thread.sleep(500);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
// if("操作过于频繁,请稍后再试!".equals(e.getErrMsg()) && new Random().nextBoolean()){
// try {
// Thread.sleep(500);
// } catch (InterruptedException ex) {
// ex.printStackTrace();
// }
// }
} catch (Exception e) {
e.printStackTrace();
logger.warn("Thread ID: {},未知异常", Thread.currentThread().getId());
Expand All @@ -86,15 +86,15 @@ public void startSecKill(Integer vaccineId, String startDateStr, MainFrame mainF
now = System.currentTimeMillis();
}while (now + 200 < startDate);
logger.info("###########第二波 开始秒杀###########");
for (int i = 0; i < 15; i++) {
for (int i = 0; i < 10; i++) {
service.submit(task);
}
//准点(提前20毫秒)秒杀
do {
now = System.currentTimeMillis();
}while (now + 20 < startDate);
logger.info("###########第三波 开始秒杀###########");
for (int i = 0; i < 15; i++) {
for (int i = 0; i < 30; i++) {
service.submit(task);
}

Expand Down

0 comments on commit bf71471

Please sign in to comment.