equal
deleted
inserted
replaced
188 // test 2 - acquire try and check that lock throws OverlappingFileLockException |
188 // test 2 - acquire try and check that lock throws OverlappingFileLockException |
189 fl = ch.tryLock(); |
189 fl = ch.tryLock(); |
190 if (fl == null) |
190 if (fl == null) |
191 throw new RuntimeException("Unable to acquire lock"); |
191 throw new RuntimeException("Unable to acquire lock"); |
192 try { |
192 try { |
193 ch.lock(null, new CompletionHandler<FileLock,Void> () { |
193 ch.lock((Void)null, new CompletionHandler<FileLock,Void> () { |
194 public void completed(FileLock result, Void att) { |
194 public void completed(FileLock result, Void att) { |
195 } |
195 } |
196 public void failed(Throwable exc, Void att) { |
196 public void failed(Throwable exc, Void att) { |
197 } |
197 } |
198 public void cancelled(Void att) { |
198 public void cancelled(Void att) { |
215 System.out.println("testInterruptHandlerThread"); |
215 System.out.println("testInterruptHandlerThread"); |
216 |
216 |
217 ByteBuffer buf = ByteBuffer.allocateDirect(100); |
217 ByteBuffer buf = ByteBuffer.allocateDirect(100); |
218 final CountDownLatch latch = new CountDownLatch(1); |
218 final CountDownLatch latch = new CountDownLatch(1); |
219 |
219 |
220 ch.read(buf, 0L, null, new CompletionHandler<Integer,Void>() { |
220 ch.read(buf, 0L, (Void)null, new CompletionHandler<Integer,Void>() { |
221 public void completed(Integer result, Void att) { |
221 public void completed(Integer result, Void att) { |
222 try { |
222 try { |
223 Thread.currentThread().interrupt(); |
223 Thread.currentThread().interrupt(); |
224 long size = ch.size(); |
224 long size = ch.size(); |
225 latch.countDown(); |
225 latch.countDown(); |
309 for (int i=0; i<10; i++) { |
309 for (int i=0; i<10; i++) { |
310 // do I/O operation to see which thread invokes the completion handler |
310 // do I/O operation to see which thread invokes the completion handler |
311 final AtomicReference<Thread> invoker = new AtomicReference<Thread>(); |
311 final AtomicReference<Thread> invoker = new AtomicReference<Thread>(); |
312 final CountDownLatch latch = new CountDownLatch(1); |
312 final CountDownLatch latch = new CountDownLatch(1); |
313 |
313 |
314 ch.write(genBuffer(), 0L, null, new CompletionHandler<Integer,Void>() { |
314 ch.write(genBuffer(), 0L, (Void)null, new CompletionHandler<Integer,Void>() { |
315 public void completed(Integer result, Void att) { |
315 public void completed(Integer result, Void att) { |
316 invoker.set(Thread.currentThread()); |
316 invoker.set(Thread.currentThread()); |
317 latch.countDown(); |
317 latch.countDown(); |
318 } |
318 } |
319 public void failed(Throwable exc, Void att) { |
319 public void failed(Throwable exc, Void att) { |
408 AsynchronousFileChannel ch = AsynchronousFileChannel |
408 AsynchronousFileChannel ch = AsynchronousFileChannel |
409 .open(file, WRITE, SYNC); |
409 .open(file, WRITE, SYNC); |
410 |
410 |
411 // start write operation |
411 // start write operation |
412 final CountDownLatch latch = new CountDownLatch(1); |
412 final CountDownLatch latch = new CountDownLatch(1); |
413 Future<Integer> res = ch.write(genBuffer(), 0L, null, |
413 Future<Integer> res = ch.write(genBuffer(), 0L, (Void)null, |
414 new CompletionHandler<Integer,Void>() { |
414 new CompletionHandler<Integer,Void>() { |
415 public void completed(Integer result, Void att) { |
415 public void completed(Integer result, Void att) { |
416 } |
416 } |
417 public void failed(Throwable exc, Void att) { |
417 public void failed(Throwable exc, Void att) { |
418 } |
418 } |