Skip to content
Browse files

Stand

  • Loading branch information...
1 parent a26a781 commit 635e594cba250a3acab7c108732269becf10b668 @nschlimm committed Apr 25, 2012
View
16 java7-playground/src/main/java/com/schlimm/java7/nio/openjdktests/CustomThreadPool.java
@@ -30,18 +30,26 @@
*/
import java.io.File;
-import static java.nio.file.StandardOpenOption.*;
import java.nio.ByteBuffer;
-import java.nio.channels.*;
+import java.nio.channels.AsynchronousFileChannel;
+import java.nio.channels.CompletionHandler;
+import java.nio.file.StandardOpenOption;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicReference;
public class CustomThreadPool {
public static void main(String[] args) throws Exception {
File blah = File.createTempFile("blah", null);
blah.deleteOnExit();
- AsynchronousFileChannel ch =
- AsynchronousFileChannel.open(blah.toPath(), READ, WRITE);
+ ExecutorService pool = Executors.newFixedThreadPool(50, new MyThreadFactory());
+ AsynchronousFileChannel ch =
+ AsynchronousFileChannel.open(blah.toPath(),
+ new HashSet<StandardOpenOption>(Arrays.asList(StandardOpenOption.READ, StandardOpenOption.WRITE,
+ StandardOpenOption.CREATE, StandardOpenOption.DELETE_ON_CLOSE)), pool );
ByteBuffer src = ByteBuffer.wrap("Scooby Snacks".getBytes());
final AtomicReference<Thread> invoker = new AtomicReference<Thread>();
View
2 java7-playground/src/main/java/com/schlimm/java7/nio/openjdktests/Lock.java
@@ -161,7 +161,7 @@ static LockSlaveMirror startLockSlave() throws Exception {
String testClasses = System.getProperty("test.classes");
if (testClasses != null)
command += " -cp " + testClasses;
- command += " Lock -lockslave " + port;
+ command += " com.schlimm.java7.nio.openjdktests.Lock -lockslave " + port;
Process p = Runtime.getRuntime().exec(command);
IOHandler.handle(p.getInputStream());

0 comments on commit 635e594

Please sign in to comment.
Something went wrong with that request. Please try again.