问题
I am using java nio filechannel transferFrom function along with Apache httpclient to download files from internet. Its starts normally but cpu usage suddenly grows after some time. And download speed decreases and eventually becomes zero.
try (CloseableHttpResponse response = client.execute(get);
ReadableByteChannel inputChannel = Channels.newChannel(
response.getEntity().getContent())) {
while (start < end && currentState.get() == 1) {
delta = fileChannel.transferFrom(inputChannel, start, 8192);
start += delta;
bytesDone.addAndGet(delta);
intialState.set(name, start);
}
}
Sry cant post images due to low reputation
来源:https://stackoverflow.com/questions/25590129/java-filechannel-cpu-usage-growing-with-time