Too Many Threads Exception

ぃ、小莉子 提交于 2019-12-01 10:34:56

Reuse the threads, queue up all the images, and run just a couple of threads, each processing one image at a time and then moving on to the next.

There is a reason the unit only allows 16 per process, and it has to do with resources. You basically have to make do with fewer threads.

You run into a similar limitation with older browsers like IE6 which limit you to 2 concurrent connections per domain.

Re-use the threads and download the images serially on fewer concurrent threads (perhaps using 2-3 threads to speed things up).

Just speculating here, but tying up all 16 threads seems like it could lead to an unstable environment since the BB OS is doing other things while your program is running.

I have been taught that creating threads dynamically is almost never an good approach, I would have created 1-2 worker threads with an queue that would do the job for me.

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