java filechannel cpu usage growing with time

笑着哭i 提交于 2019-12-02 14:31:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!