java filechannel cpu usage growing with time

2019-03-04 13:34发布

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

0条回答
登录 后发表回答