private static void loopWait() throws Exception { atomicBoolean.lazySet(true); // atomicBoolean.set(true); // volatileField = true; // Thread.yield(); // LockSupport.parkNanos(1); // Thread.sleep(1); // ## IPC latency results ## // // Intel Core 2 Quad Q6600 @ 3.0GHz (Kentsfield), Windows 7 64-bit // 1 cache line 2 cache lines // lazySet() // set() // volatile 99.9 ns 125.55 ns // yield() 208.25 ns // parkNanos(1) 695000.0 ns // sleep(1) 704000.0 ns // none deadlock deadlock // // Intel Core i7 860 @ 2.8GHz (Lynnfield), Windows 7 64-bit, jdk1.7.0_17 64-bit // 1 cache line 2 cache lines // lazySet() 68.85 ns 91.9 ns // set() 47.7 ns 95.0 ns // volatile 47.65-78.6 ns 91.65 ns // yield() 74.1 ns 110.3 ns // parkNanos(1) 640900.0 ns 691700.0 ns // sleep(1) 711150.0 ns 655000.0 ns // none deadlock deadlock }
/** Indicates the method {@link #put(Object)} will not be called in the queue anymore. */ public void done() { // Lazily set here, and then come back in handleClose and use set if necessary done.lazySet(true); try { queue.add(afterLast); } catch (IllegalStateException e) { // no thread is waiting on this queue anyway } }
/** * @param keyIndex the index of the key that has changed, the list of keys is provided by the * constructor {@link KeyInterestUpdater(int, SelectionKey[])} */ public void set(int keyIndex) { changeOfOpWriteRequired.set(keyIndex); wasChanged.lazySet(true); }
@Override public void forceBootstrap() { forceBootstrap.lazySet(true); }