7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @summary Check that appends are atomic
27 */
28
29 import java.io.File;
30 import java.io.FileOutputStream;
31 import java.io.OutputStream;
32 import java.io.IOException;
33 import java.util.Random;
34 import java.util.concurrent.Executors;
35 import java.util.concurrent.ExecutorService;
36 import java.util.concurrent.TimeUnit;
37 import java.nio.ByteBuffer;
38 import java.nio.channels.FileChannel;
39 import java.nio.file.Files;
40 import static java.nio.file.StandardOpenOption.*;
41
42 public class AtomicAppend {
43 static final Random rand = new Random();
44
45 // Open file for appending, returning FileChannel
46 static FileChannel newFileChannel(File file) throws IOException {
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @summary Check that appends are atomic
27 * @key randomness
28 */
29
30 import java.io.File;
31 import java.io.FileOutputStream;
32 import java.io.OutputStream;
33 import java.io.IOException;
34 import java.util.Random;
35 import java.util.concurrent.Executors;
36 import java.util.concurrent.ExecutorService;
37 import java.util.concurrent.TimeUnit;
38 import java.nio.ByteBuffer;
39 import java.nio.channels.FileChannel;
40 import java.nio.file.Files;
41 import static java.nio.file.StandardOpenOption.*;
42
43 public class AtomicAppend {
44 static final Random rand = new Random();
45
46 // Open file for appending, returning FileChannel
47 static FileChannel newFileChannel(File file) throws IOException {
|