Browse Source

while -> if

yegang 3 years ago
parent
commit
ca58182064
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/main/java/com/sw/service/impl/SnatchMaskServiceImpl.java

+ 2 - 2
src/main/java/com/sw/service/impl/SnatchMaskServiceImpl.java

@@ -161,12 +161,12 @@ public class SnatchMaskServiceImpl implements SnatchMaskService {
         String threadName = Thread.currentThread().getName();
 
         try {
-            while (lock.tryLock(1000, TimeUnit.MILLISECONDS)) {
+            if (lock.tryLock(1000, TimeUnit.MILLISECONDS)) {
                 log.info("线程:{} 获取锁", threadName);
                 log.info("doSnatch方法执行结果:{}", this.doSnatch(uid, maskId));
                 lock.unlock();
                 log.info("{}:业务执行完成", threadName);
-                break;
+//                break;
             }
         } catch(InterruptedException e){
                 e.printStackTrace();