我有一个为不同的电子邮件地址发送电子邮件的java进程,我正在使用java线程池执行程序,每个线程都尝试发送电子邮件然后退出
问题是所有线程都将进入等待状态,即使线程已成功完成工作,也永远无法回到运行状态,
我的threadPoolExecutor配置如下,
队列大小 = 100 线程数 = 5 最大线程数 = 10 保持活动时间 = 1 分钟
这是线程转储,但我不明白它在说什么
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x2808f538> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
at java.util.concurrent.ArrayBlockingQueue.take(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
这是代码:
ReqtQueue = new ArrayBlockingQueue<Runnable>(100, true);
notifTaskExecutor = new ThreadPoolExecutor(
5, // core size of threads that will remain in idle state
10, // max size of thread that can be created
1, // keep alive time for thread other than number of core threads when they are in idel state
TimeUnit.MINUTES, // keep alive time units
ReqtQueue // the queue to use
);
并调用执行方法:
notifTaskExecutor.execute(new NotificationSender(request, name));
NotificationSender 只是发送电子邮件,所有代码都在 try catch 中,非常简单,即使 run 方法为空,线程也不会终止
需要帮助
问候