Reza Reza - 30 days ago 8
Android Question

When to use ThreadPoolExecutor instead newThread()

I have a http server which is gonna be really busy, there are few HttpHandlers inside it which all of them start their job with a new

, since i still can not compeletely understand ThreadPoolExecutor's Usage (When you should use, when no need to), i really could use a little tip about it and do i need to use one?

Plus is there any roof for the threadPoolExecutor's max Threads ?

Same goes for the android, i dont understand why should i use ThreadPoolExecutor instead simply use

Answer Source

Basically ThreadPoolExecutor is just a high level API from java to do task in multiple thread without dealing with low level API (Creating thread manually)

For a little example a ExecutorService executor = Executors.newFixedThreadPool(5); will run the tasks you submit in 8 threads.

You can try to understand it more by reading this documentation.
and this tutorial