Authored by 张帅

fix

@@ -21,6 +21,8 @@ import org.springframework.stereotype.Service; @@ -21,6 +21,8 @@ import org.springframework.stereotype.Service;
21 21
22 import javax.annotation.PostConstruct; 22 import javax.annotation.PostConstruct;
23 import java.util.*; 23 import java.util.*;
  24 +import java.util.concurrent.ExecutorService;
  25 +import java.util.concurrent.Executors;
24 import java.util.concurrent.TimeUnit; 26 import java.util.concurrent.TimeUnit;
25 import java.util.stream.Collectors; 27 import java.util.stream.Collectors;
26 import static com.yoho.tools.common.utils.RandomUtil.getRandom; 28 import static com.yoho.tools.common.utils.RandomUtil.getRandom;
@@ -66,12 +68,14 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ @@ -66,12 +68,14 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{
66 68
67 private static final int recPraise = 2; 69 private static final int recPraise = 2;
68 70
  71 + private ExecutorService executorService = Executors.newSingleThreadExecutor();
  72 +
69 private static final String MESSAGE_KEY = "yh:pfcms:grass:auto_praise:list"; 73 private static final String MESSAGE_KEY = "yh:pfcms:grass:auto_praise:list";
70 private static final String MESSAGE_SENDING_FLAG = "yh:pfcms:grass:auto_praise:sending"; 74 private static final String MESSAGE_SENDING_FLAG = "yh:pfcms:grass:auto_praise:sending";
71 75
72 @PostConstruct 76 @PostConstruct
73 public void startSendMessageTask(){ 77 public void startSendMessageTask(){
74 - new Thread(() -> { 78 + executorService.execute(() -> {
75 while(true){ 79 while(true){
76 List<GrassInBoxAddReq> messageList = platformRedis.range(MESSAGE_KEY, "all", 80 List<GrassInBoxAddReq> messageList = platformRedis.range(MESSAGE_KEY, "all",
77 GrassInBoxAddReq.class, 0, -1); 81 GrassInBoxAddReq.class, 0, -1);
@@ -119,7 +123,7 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ @@ -119,7 +123,7 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{
119 e.printStackTrace(); 123 e.printStackTrace();
120 } 124 }
121 } 125 }
122 - }).start(); 126 + });
123 } 127 }
124 128
125 /** 129 /**