Changeset 7755
- Timestamp:
- Nov 26, 2019, 2:03:58 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.15-stable/src/core/net/sf/basedb/util/timer/ThreadTimerTask.java
r6684 r7755 43 43 { 44 44 45 private static final org.slf4j.Logger log = 46 org.slf4j.LoggerFactory.getLogger(ThreadTimerTask.class); 47 45 48 private final TimerTask task; 46 49 private final boolean allowMultiple; … … 69 72 public final synchronized void run() 70 73 { 71 Thread t = null; 72 if (allowMultiple) 74 try 73 75 { 74 // We just create another thread75 t = new Thread(task);76 }77 else if (!isExecuting)78 {79 // Create a new thread that also manages the isExecuting flag80 isExecuting = true;81 t = new Thread(82 new Runnable()83 {84 @Override85 public void run()76 Thread t = null; 77 if (allowMultiple) 78 { 79 // We just create another thread 80 t = new Thread(task); 81 } 82 else if (!isExecuting) 83 { 84 // Create a new thread that also manages the isExecuting flag 85 isExecuting = true; 86 t = new Thread( 87 new Runnable() 86 88 { 87 try 89 @Override 90 public void run() 88 91 { 89 task.run(); 90 } 91 finally 92 { 93 isExecuting = false; 92 try 93 { 94 task.run(); 95 } 96 finally 97 { 98 isExecuting = false; 99 } 94 100 } 95 101 } 96 } 97 ); 102 ); 103 } 104 else 105 { 106 // Do not allow multiple thread to execute the task 107 } 108 // Start the thread 109 if (t != null) t.start(); 98 110 } 99 else111 catch (Throwable t) 100 112 { 101 // Do not allow multiple thread to execute the task113 log.error("Failed to start task: " + task, t); 102 114 } 103 // Start the thread104 if (t != null) t.start();105 115 } 106 116 @Override
Note: See TracChangeset
for help on using the changeset viewer.