I have to use Java ThreadPoolExecutor in one of my component in Android. I was searching the use of allowCoreThreadTimeout( ).
I have read the Java & Android docs related. But I didn't get any useful implementation scenario of the method. Can someone please help me??
This method allows you to specify whether to terminate the core thread if there is no incoming task within the thread keep alive time. This is related to other configuration like, setCorePoolSize(), setKeepAliveTime(..)
When you are creating a thread pool and idle threads exist in the pool even though there is no task is running. It is costly to keep these thread alive. If you want get rid of these when you have no task to execute, this method is useful. You need to pass true value then they will be die after the keep alive time.
In Summary:
allowCoreThreadTimeOut(true) // Could save memory compromising performance
allowCoreThreadTimeOut(false) // Comsume memory but high performance