- Timestamp:
- 07/16/13 23:31:35 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/util/dispatching/Monitor.java
r100 r102 5 5 import com.framsticks.util.dispatching.Dispatching; 6 6 import java.lang.Thread; 7 import java.util.concurrent.atomic.AtomicBoolean; 7 8 8 9 public class Monitor implements JoinableParent { … … 12 13 protected final Joinable joinable; 13 14 protected final Thread shutdownHook; 15 protected final AtomicBoolean dropped = new AtomicBoolean(false); 16 protected final AtomicBoolean joining = new AtomicBoolean(false); 14 17 15 18 /** … … 22 25 @Override 23 26 public void run() { 24 log.debug(" running shutdown hook");27 log.debug("droping and joining"); 25 28 Monitor.this.drop().join(); 29 log.debug("droped and joined"); 30 AbstractJoinable.report(); 26 31 } 27 32 }); … … 54 59 55 60 public Monitor drop() { 61 if (!dropped.compareAndSet(false, true)) { 62 return this; 63 } 56 64 log.debug("{} is droping", this); 57 65 Dispatching.drop(joinable, this); … … 60 68 61 69 public Monitor join() { 70 if (!joining.compareAndSet(false, true)) { 71 log.debug("not joining"); 72 return this; 73 } 74 62 75 log.debug("{} is joining", this); 63 76 Dispatching.joinAbsolutely(joinable); … … 69 82 /** In case IllegalStateException is caught, it means that JVM is in finalization stage */ 70 83 } 71 72 84 return this; 73 85 }
Note: See TracChangeset
for help on using the changeset viewer.