multithreading - Java ThreadPoolExecutor Hangs while processing -
i having custom thread pool executor
public class customtpexecutor extends threadpoolexecutor { /* constructor called processor */ public customtpexecutor (int corepoolsize, int maxpoolsize, long keepalivetime, timeunit timeunit, blockingqueue<runnable> blockingqueue, threadfactory threadfactory,processor processor) { super(corepoolsize, maxpoolsize, keepalivetime, timeunit, blockingqueue,threadfactory); this.processor = processor; } @override protected void afterexecute(runnable paramrunnable, throwable paramthrowable) { super.afterexecute(paramrunnable, paramthrowable); /* notify processor more records */ } }
in processor, creating instances customtpexecutor , submit more 1000+ tasks it. maximum pool size 5.
for submitting executor use this.
while(iterating map events containing 1000+records) { customthread tt = new txntcustomthread(eventmap.get(key), key,maxdate,connpool,connpool.getconnection(),email); executor.submit(tt); }
after processing records calling executor shutdown method.
one thing noticing that, while threads executing hangs sometime in middle of processing. pauses minute or , resumes processing records. not sure reaosn this.
i assuming because of garbage collection not happening. cannot logs debug on this. during process memory consumption java reduced drastically.
any suggestions on how issue resolved helpful.
there's such thing "stop-the-world" gc, speaking means jvm decided needs such "deep clean" temporarily stops of threads prevent references changing. not desired , gc tries avoid in favor of doing gc in background. can happen though, if you're using of cores computation (which may tend prevent background gc) , you're generating lot of objects.
if search online "stop-the-world gc" you'll hits.
Comments
Post a Comment