adding support for cache & thread for Max pain calculation