Javamail:为IMAPFolder发出idle()的正确方法 [英] Javamail : Proper way to issue idle() for IMAPFolder
本文介绍了Javamail:为IMAPFolder发出idle()的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经为IMAPFolder设置了MessageCountListener.为了连续获取更新,我必须执行以下操作,这对于我的应用程序性能而言是致命的.因为它在每个文件夹中都运行,所以它冻结了GUI.
I have set MessageCountListener for IMAPFolder. In order to get updates continuously I had to do the following, which is a killer for my app performance wise. It freezes the GUI since it's running for each and every folder.
while (true) {
try {
if (folder != null && folder.isOpen()) {
folder.idle();
} else {
getSyncListenersAttachedFolders().remove(syncFolder.getFolderID());
}
} catch (Exception ex) {
errorLOG.error("IDLE command issue exception.");
getSyncListenersAttachedFolders().remove(syncFolder.getFolderID());
}
}
有没有更好的方法来发出空闲命令,而该空闲命令不会在while(true)条件下运行. 期待快速响应.预先感谢.
Is there any better way of issuing idle command which will not run in a while(true) condition. Expecting a quick response. Thanks in advance.
推荐答案
您需要在自己的线程中运行它.
You need to run it in its own thread.
这篇关于Javamail:为IMAPFolder发出idle()的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文