Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
b315e54c
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b315e54c
编写于
4月 17, 2013
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8012019: (fc) Thread.interrupt triggers hang in FileChannelImpl.pread (win)
Reviewed-by: chegar
上级
0b6e29e7
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
213 addition
and
46 deletion
+213
-46
src/share/classes/sun/nio/ch/DatagramChannelImpl.java
src/share/classes/sun/nio/ch/DatagramChannelImpl.java
+2
-2
src/share/classes/sun/nio/ch/FileChannelImpl.java
src/share/classes/sun/nio/ch/FileChannelImpl.java
+26
-4
src/share/classes/sun/nio/ch/IOUtil.java
src/share/classes/sun/nio/ch/IOUtil.java
+10
-12
src/share/classes/sun/nio/ch/NativeDispatcher.java
src/share/classes/sun/nio/ch/NativeDispatcher.java
+12
-4
src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java
...classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java
+2
-2
src/share/classes/sun/nio/ch/SocketChannelImpl.java
src/share/classes/sun/nio/ch/SocketChannelImpl.java
+2
-2
src/solaris/classes/sun/nio/ch/FileDispatcherImpl.java
src/solaris/classes/sun/nio/ch/FileDispatcherImpl.java
+5
-4
src/solaris/classes/sun/nio/ch/SinkChannelImpl.java
src/solaris/classes/sun/nio/ch/SinkChannelImpl.java
+1
-1
src/solaris/classes/sun/nio/ch/SourceChannelImpl.java
src/solaris/classes/sun/nio/ch/SourceChannelImpl.java
+1
-1
src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java
...classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java
+4
-4
src/windows/classes/sun/nio/ch/FileDispatcherImpl.java
src/windows/classes/sun/nio/ch/FileDispatcherImpl.java
+11
-10
test/java/nio/channels/FileChannel/InterruptDeadlock.java
test/java/nio/channels/FileChannel/InterruptDeadlock.java
+137
-0
未找到文件。
src/share/classes/sun/nio/ch/DatagramChannelImpl.java
浏览文件 @
b315e54c
...
...
@@ -538,7 +538,7 @@ class DatagramChannelImpl
return
0
;
readerThread
=
NativeThread
.
current
();
do
{
n
=
IOUtil
.
read
(
fd
,
buf
,
-
1
,
nd
,
readLock
);
n
=
IOUtil
.
read
(
fd
,
buf
,
-
1
,
nd
);
}
while
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
());
return
IOStatus
.
normalize
(
n
);
}
finally
{
...
...
@@ -594,7 +594,7 @@ class DatagramChannelImpl
return
0
;
writerThread
=
NativeThread
.
current
();
do
{
n
=
IOUtil
.
write
(
fd
,
buf
,
-
1
,
nd
,
writeLock
);
n
=
IOUtil
.
write
(
fd
,
buf
,
-
1
,
nd
);
}
while
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
());
return
IOStatus
.
normalize
(
n
);
}
finally
{
...
...
src/share/classes/sun/nio/ch/FileChannelImpl.java
浏览文件 @
b315e54c
...
...
@@ -140,7 +140,7 @@ public class FileChannelImpl
if
(!
isOpen
())
return
0
;
do
{
n
=
IOUtil
.
read
(
fd
,
dst
,
-
1
,
nd
,
positionLock
);
n
=
IOUtil
.
read
(
fd
,
dst
,
-
1
,
nd
);
}
while
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
());
return
IOStatus
.
normalize
(
n
);
}
finally
{
...
...
@@ -192,7 +192,7 @@ public class FileChannelImpl
if
(!
isOpen
())
return
0
;
do
{
n
=
IOUtil
.
write
(
fd
,
src
,
-
1
,
nd
,
positionLock
);
n
=
IOUtil
.
write
(
fd
,
src
,
-
1
,
nd
);
}
while
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
());
return
IOStatus
.
normalize
(
n
);
}
finally
{
...
...
@@ -671,6 +671,17 @@ public class FileChannelImpl
if
(!
readable
)
throw
new
NonReadableChannelException
();
ensureOpen
();
if
(
nd
.
needsPositionLock
())
{
synchronized
(
positionLock
)
{
return
readInternal
(
dst
,
position
);
}
}
else
{
return
readInternal
(
dst
,
position
);
}
}
private
int
readInternal
(
ByteBuffer
dst
,
long
position
)
throws
IOException
{
assert
!
nd
.
needsPositionLock
()
||
Thread
.
holdsLock
(
positionLock
);
int
n
=
0
;
int
ti
=
-
1
;
try
{
...
...
@@ -679,7 +690,7 @@ public class FileChannelImpl
if
(!
isOpen
())
return
-
1
;
do
{
n
=
IOUtil
.
read
(
fd
,
dst
,
position
,
nd
,
positionLock
);
n
=
IOUtil
.
read
(
fd
,
dst
,
position
,
nd
);
}
while
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
());
return
IOStatus
.
normalize
(
n
);
}
finally
{
...
...
@@ -697,6 +708,17 @@ public class FileChannelImpl
if
(!
writable
)
throw
new
NonWritableChannelException
();
ensureOpen
();
if
(
nd
.
needsPositionLock
())
{
synchronized
(
positionLock
)
{
return
writeInternal
(
src
,
position
);
}
}
else
{
return
writeInternal
(
src
,
position
);
}
}
private
int
writeInternal
(
ByteBuffer
src
,
long
position
)
throws
IOException
{
assert
!
nd
.
needsPositionLock
()
||
Thread
.
holdsLock
(
positionLock
);
int
n
=
0
;
int
ti
=
-
1
;
try
{
...
...
@@ -705,7 +727,7 @@ public class FileChannelImpl
if
(!
isOpen
())
return
-
1
;
do
{
n
=
IOUtil
.
write
(
fd
,
src
,
position
,
nd
,
positionLock
);
n
=
IOUtil
.
write
(
fd
,
src
,
position
,
nd
);
}
while
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
());
return
IOStatus
.
normalize
(
n
);
}
finally
{
...
...
src/share/classes/sun/nio/ch/IOUtil.java
浏览文件 @
b315e54c
...
...
@@ -44,11 +44,11 @@ public class IOUtil {
private
IOUtil
()
{
}
// No instantiation
static
int
write
(
FileDescriptor
fd
,
ByteBuffer
src
,
long
position
,
NativeDispatcher
nd
,
Object
lock
)
NativeDispatcher
nd
)
throws
IOException
{
if
(
src
instanceof
DirectBuffer
)
return
writeFromNativeBuffer
(
fd
,
src
,
position
,
nd
,
lock
);
return
writeFromNativeBuffer
(
fd
,
src
,
position
,
nd
);
// Substitute a native buffer
int
pos
=
src
.
position
();
...
...
@@ -62,7 +62,7 @@ public class IOUtil {
// Do not update src until we see how many bytes were written
src
.
position
(
pos
);
int
n
=
writeFromNativeBuffer
(
fd
,
bb
,
position
,
nd
,
lock
);
int
n
=
writeFromNativeBuffer
(
fd
,
bb
,
position
,
nd
);
if
(
n
>
0
)
{
// now update src
src
.
position
(
pos
+
n
);
...
...
@@ -74,8 +74,7 @@ public class IOUtil {
}
private
static
int
writeFromNativeBuffer
(
FileDescriptor
fd
,
ByteBuffer
bb
,
long
position
,
NativeDispatcher
nd
,
Object
lock
)
long
position
,
NativeDispatcher
nd
)
throws
IOException
{
int
pos
=
bb
.
position
();
...
...
@@ -89,7 +88,7 @@ public class IOUtil {
if
(
position
!=
-
1
)
{
written
=
nd
.
pwrite
(
fd
,
((
DirectBuffer
)
bb
).
address
()
+
pos
,
rem
,
position
,
lock
);
rem
,
position
);
}
else
{
written
=
nd
.
write
(
fd
,
((
DirectBuffer
)
bb
).
address
()
+
pos
,
rem
);
}
...
...
@@ -184,18 +183,18 @@ public class IOUtil {
}
static
int
read
(
FileDescriptor
fd
,
ByteBuffer
dst
,
long
position
,
NativeDispatcher
nd
,
Object
lock
)
NativeDispatcher
nd
)
throws
IOException
{
if
(
dst
.
isReadOnly
())
throw
new
IllegalArgumentException
(
"Read-only buffer"
);
if
(
dst
instanceof
DirectBuffer
)
return
readIntoNativeBuffer
(
fd
,
dst
,
position
,
nd
,
lock
);
return
readIntoNativeBuffer
(
fd
,
dst
,
position
,
nd
);
// Substitute a native buffer
ByteBuffer
bb
=
Util
.
getTemporaryDirectBuffer
(
dst
.
remaining
());
try
{
int
n
=
readIntoNativeBuffer
(
fd
,
bb
,
position
,
nd
,
lock
);
int
n
=
readIntoNativeBuffer
(
fd
,
bb
,
position
,
nd
);
bb
.
flip
();
if
(
n
>
0
)
dst
.
put
(
bb
);
...
...
@@ -206,8 +205,7 @@ public class IOUtil {
}
private
static
int
readIntoNativeBuffer
(
FileDescriptor
fd
,
ByteBuffer
bb
,
long
position
,
NativeDispatcher
nd
,
Object
lock
)
long
position
,
NativeDispatcher
nd
)
throws
IOException
{
int
pos
=
bb
.
position
();
...
...
@@ -220,7 +218,7 @@ public class IOUtil {
int
n
=
0
;
if
(
position
!=
-
1
)
{
n
=
nd
.
pread
(
fd
,
((
DirectBuffer
)
bb
).
address
()
+
pos
,
rem
,
position
,
lock
);
rem
,
position
);
}
else
{
n
=
nd
.
read
(
fd
,
((
DirectBuffer
)
bb
).
address
()
+
pos
,
rem
);
}
...
...
src/share/classes/sun/nio/ch/NativeDispatcher.java
浏览文件 @
b315e54c
...
...
@@ -38,8 +38,16 @@ abstract class NativeDispatcher
abstract
int
read
(
FileDescriptor
fd
,
long
address
,
int
len
)
throws
IOException
;
int
pread
(
FileDescriptor
fd
,
long
address
,
int
len
,
long
position
,
Object
lock
)
throws
IOException
/**
* Returns {@code true} if pread/pwrite needs to be synchronized with
* position sensitive methods.
*/
boolean
needsPositionLock
()
{
return
false
;
}
int
pread
(
FileDescriptor
fd
,
long
address
,
int
len
,
long
position
)
throws
IOException
{
throw
new
IOException
(
"Operation Unsupported"
);
}
...
...
@@ -50,8 +58,8 @@ abstract class NativeDispatcher
abstract
int
write
(
FileDescriptor
fd
,
long
address
,
int
len
)
throws
IOException
;
int
pwrite
(
FileDescriptor
fd
,
long
address
,
int
len
,
long
position
,
Object
lock
)
throws
IOException
int
pwrite
(
FileDescriptor
fd
,
long
address
,
int
len
,
long
position
)
throws
IOException
{
throw
new
IOException
(
"Operation Unsupported"
);
}
...
...
src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java
浏览文件 @
b315e54c
...
...
@@ -318,7 +318,7 @@ public class SimpleAsynchronousFileChannelImpl
try
{
begin
();
do
{
n
=
IOUtil
.
read
(
fdObj
,
dst
,
position
,
nd
,
null
);
n
=
IOUtil
.
read
(
fdObj
,
dst
,
position
,
nd
);
}
while
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
());
if
(
n
<
0
&&
!
isOpen
())
throw
new
AsynchronousCloseException
();
...
...
@@ -372,7 +372,7 @@ public class SimpleAsynchronousFileChannelImpl
try
{
begin
();
do
{
n
=
IOUtil
.
write
(
fdObj
,
src
,
position
,
nd
,
null
);
n
=
IOUtil
.
write
(
fdObj
,
src
,
position
,
nd
);
}
while
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
());
if
(
n
<
0
&&
!
isOpen
())
throw
new
AsynchronousCloseException
();
...
...
src/share/classes/sun/nio/ch/SocketChannelImpl.java
浏览文件 @
b315e54c
...
...
@@ -356,7 +356,7 @@ class SocketChannelImpl
// except that the shutdown operation plays the role of
// nd.preClose().
for
(;;)
{
n
=
IOUtil
.
read
(
fd
,
buf
,
-
1
,
nd
,
readLock
);
n
=
IOUtil
.
read
(
fd
,
buf
,
-
1
,
nd
);
if
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
())
{
// The system call was interrupted but the channel
// is still open, so retry
...
...
@@ -447,7 +447,7 @@ class SocketChannelImpl
writerThread
=
NativeThread
.
current
();
}
for
(;;)
{
n
=
IOUtil
.
write
(
fd
,
buf
,
-
1
,
nd
,
writeLock
);
n
=
IOUtil
.
write
(
fd
,
buf
,
-
1
,
nd
);
if
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
())
continue
;
return
IOStatus
.
normalize
(
n
);
...
...
src/solaris/classes/sun/nio/ch/FileDispatcherImpl.java
浏览文件 @
b315e54c
...
...
@@ -46,8 +46,9 @@ class FileDispatcherImpl extends FileDispatcher
return
read0
(
fd
,
address
,
len
);
}
int
pread
(
FileDescriptor
fd
,
long
address
,
int
len
,
long
position
,
Object
lock
)
throws
IOException
{
int
pread
(
FileDescriptor
fd
,
long
address
,
int
len
,
long
position
)
throws
IOException
{
return
pread0
(
fd
,
address
,
len
,
position
);
}
...
...
@@ -59,8 +60,8 @@ class FileDispatcherImpl extends FileDispatcher
return
write0
(
fd
,
address
,
len
);
}
int
pwrite
(
FileDescriptor
fd
,
long
address
,
int
len
,
long
position
,
Object
lock
)
throws
IOException
int
pwrite
(
FileDescriptor
fd
,
long
address
,
int
len
,
long
position
)
throws
IOException
{
return
pwrite0
(
fd
,
address
,
len
,
position
);
}
...
...
src/solaris/classes/sun/nio/ch/SinkChannelImpl.java
浏览文件 @
b315e54c
...
...
@@ -165,7 +165,7 @@ class SinkChannelImpl
return
0
;
thread
=
NativeThread
.
current
();
do
{
n
=
IOUtil
.
write
(
fd
,
src
,
-
1
,
nd
,
lock
);
n
=
IOUtil
.
write
(
fd
,
src
,
-
1
,
nd
);
}
while
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
());
return
IOStatus
.
normalize
(
n
);
}
finally
{
...
...
src/solaris/classes/sun/nio/ch/SourceChannelImpl.java
浏览文件 @
b315e54c
...
...
@@ -165,7 +165,7 @@ class SourceChannelImpl
return
0
;
thread
=
NativeThread
.
current
();
do
{
n
=
IOUtil
.
read
(
fd
,
dst
,
-
1
,
nd
,
lock
);
n
=
IOUtil
.
read
(
fd
,
dst
,
-
1
,
nd
);
}
while
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
());
return
IOStatus
.
normalize
(
n
);
}
finally
{
...
...
src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java
浏览文件 @
b315e54c
...
...
@@ -384,7 +384,7 @@ class UnixAsynchronousSocketChannelImpl
if
(
scattering
)
{
n
=
(
int
)
IOUtil
.
read
(
fd
,
readBuffers
,
nd
);
}
else
{
n
=
IOUtil
.
read
(
fd
,
readBuffer
,
-
1
,
nd
,
null
);
n
=
IOUtil
.
read
(
fd
,
readBuffer
,
-
1
,
nd
);
}
if
(
n
==
IOStatus
.
UNAVAILABLE
)
{
// spurious wakeup, is this possible?
...
...
@@ -505,7 +505,7 @@ class UnixAsynchronousSocketChannelImpl
if
(
isScatteringRead
)
{
n
=
(
int
)
IOUtil
.
read
(
fd
,
dsts
,
nd
);
}
else
{
n
=
IOUtil
.
read
(
fd
,
dst
,
-
1
,
nd
,
null
);
n
=
IOUtil
.
read
(
fd
,
dst
,
-
1
,
nd
);
}
}
...
...
@@ -579,7 +579,7 @@ class UnixAsynchronousSocketChannelImpl
if
(
gathering
)
{
n
=
(
int
)
IOUtil
.
write
(
fd
,
writeBuffers
,
nd
);
}
else
{
n
=
IOUtil
.
write
(
fd
,
writeBuffer
,
-
1
,
nd
,
null
);
n
=
IOUtil
.
write
(
fd
,
writeBuffer
,
-
1
,
nd
);
}
if
(
n
==
IOStatus
.
UNAVAILABLE
)
{
// spurious wakeup, is this possible?
...
...
@@ -688,7 +688,7 @@ class UnixAsynchronousSocketChannelImpl
if
(
isGatheringWrite
)
{
n
=
(
int
)
IOUtil
.
write
(
fd
,
srcs
,
nd
);
}
else
{
n
=
IOUtil
.
write
(
fd
,
src
,
-
1
,
nd
,
null
);
n
=
IOUtil
.
write
(
fd
,
src
,
-
1
,
nd
);
}
}
...
...
src/windows/classes/sun/nio/ch/FileDispatcherImpl.java
浏览文件 @
b315e54c
...
...
@@ -49,18 +49,21 @@ class FileDispatcherImpl extends FileDispatcher
this
(
false
);
}
@Override
boolean
needsPositionLock
()
{
return
true
;
}
int
read
(
FileDescriptor
fd
,
long
address
,
int
len
)
throws
IOException
{
return
read0
(
fd
,
address
,
len
);
}
int
pread
(
FileDescriptor
fd
,
long
address
,
int
len
,
long
position
,
Object
lock
)
throws
IOException
int
pread
(
FileDescriptor
fd
,
long
address
,
int
len
,
long
position
)
throws
IOException
{
synchronized
(
lock
)
{
return
pread0
(
fd
,
address
,
len
,
position
);
}
return
pread0
(
fd
,
address
,
len
,
position
);
}
long
readv
(
FileDescriptor
fd
,
long
address
,
int
len
)
throws
IOException
{
...
...
@@ -71,12 +74,10 @@ class FileDispatcherImpl extends FileDispatcher
return
write0
(
fd
,
address
,
len
,
append
);
}
int
pwrite
(
FileDescriptor
fd
,
long
address
,
int
len
,
long
position
,
Object
lock
)
throws
IOException
int
pwrite
(
FileDescriptor
fd
,
long
address
,
int
len
,
long
position
)
throws
IOException
{
synchronized
(
lock
)
{
return
pwrite0
(
fd
,
address
,
len
,
position
);
}
return
pwrite0
(
fd
,
address
,
len
,
position
);
}
long
writev
(
FileDescriptor
fd
,
long
address
,
int
len
)
throws
IOException
{
...
...
test/java/nio/channels/FileChannel/InterruptDeadlock.java
0 → 100644
浏览文件 @
b315e54c
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 8012019
* @summary Tests interruption of threads doing position-based read methods in
* an attempt to provoke a deadlock between position sensitive and position
* insensitive methods
*/
import
java.nio.ByteBuffer
;
import
java.nio.channels.*
;
import
java.nio.file.*
;
import
static
java
.
nio
.
file
.
StandardOpenOption
.*;
public
class
InterruptDeadlock
{
/**
* A thread that continuously reads from a FileChannel with
* read(ByteBuffer,long). The thread terminates when interrupted and/or
* the FileChannel is closed.
*/
static
class
Reader
extends
Thread
{
final
FileChannel
fc
;
volatile
Exception
exception
;
Reader
(
FileChannel
fc
)
{
this
.
fc
=
fc
;
}
@Override
public
void
run
()
{
ByteBuffer
bb
=
ByteBuffer
.
allocate
(
1024
);
try
{
long
pos
=
0L
;
for
(;;)
{
bb
.
clear
();
int
n
=
fc
.
read
(
bb
,
pos
);
if
(
n
>
0
)
pos
+=
n
;
// fc.size is important here as it is position sensitive
if
(
pos
>
fc
.
size
())
pos
=
0L
;
}
}
catch
(
ClosedChannelException
x
)
{
System
.
out
.
println
(
x
.
getClass
()
+
" (expected)"
);
}
catch
(
Exception
unexpected
)
{
this
.
exception
=
unexpected
;
}
}
Exception
exception
()
{
return
exception
;
}
static
Reader
startReader
(
FileChannel
fc
)
{
Reader
r
=
new
Reader
(
fc
);
r
.
start
();
return
r
;
}
}
// the number of reader threads to start
private
static
final
int
READER_COUNT
=
4
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Path
file
=
Paths
.
get
(
"data.txt"
);
try
(
FileChannel
fc
=
FileChannel
.
open
(
file
,
CREATE
,
TRUNCATE_EXISTING
,
WRITE
))
{
fc
.
position
(
1024L
*
1024L
);
fc
.
write
(
ByteBuffer
.
wrap
(
new
byte
[
1
]));
}
Reader
[]
readers
=
new
Reader
[
READER_COUNT
];
for
(
int
i
=
1
;
i
<=
20
;
i
++)
{
System
.
out
.
format
(
"Iteration: %s%n"
,
i
);
try
(
FileChannel
fc
=
FileChannel
.
open
(
file
))
{
boolean
failed
=
false
;
// start reader threads
for
(
int
j
=
0
;
j
<
READER_COUNT
;
j
++)
{
readers
[
j
]
=
Reader
.
startReader
(
fc
);
}
// give readers a bit of time to get started (not strictly required)
Thread
.
sleep
(
100
);
// interrupt and wait for the readers to terminate
for
(
Reader
r:
readers
)
{
r
.
interrupt
();
}
for
(
Reader
r:
readers
)
{
try
{
r
.
join
(
10000
);
Exception
e
=
r
.
exception
();
if
(
e
!=
null
)
{
System
.
err
.
println
(
"Reader thread failed with: "
+
e
);
failed
=
true
;
}
}
catch
(
InterruptedException
x
)
{
System
.
err
.
println
(
"Reader thread did not terminte"
);
failed
=
true
;
}
}
// the channel should not be open at this point
if
(
fc
.
isOpen
())
{
System
.
err
.
println
(
"FileChannel was not closed"
);
failed
=
true
;
}
if
(
failed
)
throw
new
RuntimeException
(
"Test failed - see log for details"
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录