jdk/test/java/io/FileOutputStream/AtomicAppend.java
changeset 8559 826c03991926
parent 5506 202f599c92aa
child 9035 1255eb81cc2f
equal deleted inserted replaced
8558:e51c07113d09 8559:826c03991926
    45         try {
    45         try {
    46             final ExecutorService es = Executors.newFixedThreadPool(nThreads);
    46             final ExecutorService es = Executors.newFixedThreadPool(nThreads);
    47             for (int i = 0; i < nThreads; i++)
    47             for (int i = 0; i < nThreads; i++)
    48                 es.execute(new Runnable() { public void run() {
    48                 es.execute(new Runnable() { public void run() {
    49                     try {
    49                     try {
    50                         FileOutputStream s = new FileOutputStream(file, true);
    50                         try (FileOutputStream s = new FileOutputStream(file, true)) {
    51                         for (int j = 0; j < 1000; j++) {
    51                             for (int j = 0; j < 1000; j++) {
    52                             s.write((int) 'x');
    52                                 s.write((int) 'x');
    53                             s.flush();
    53                                 s.flush();
       
    54                             }
    54                         }
    55                         }
    55                         s.close();
       
    56                     } catch (Throwable t) { unexpected(t); }}});
    56                     } catch (Throwable t) { unexpected(t); }}});
    57             es.shutdown();
    57             es.shutdown();
    58             es.awaitTermination(10L, TimeUnit.MINUTES);
    58             es.awaitTermination(10L, TimeUnit.MINUTES);
    59             equal(file.length(), (long) (nThreads * writes));
    59             equal(file.length(), (long) (nThreads * writes));
    60         } finally {
    60         } finally {