如何中断IMAP的IDLE? [英] How can I interrupt IMAP's IDLE?
问题描述
我正在使用连接到IMAP服务器的Javamail API.javax.mail.Folder.idle()
I am using the Javamail API connecting to my IMAP server. Everything is working great with the javax.mail.Folder.idle() method. My listener gets called when a new mail comes in. However the problem is idle blocks forever, how do I interrupt it? How do I actually stop the listening without killing my Java program?
我尝试在空闲线程上调用Thread.interrupt().没发生什么事.我的想法不多了.
I've tried calling Thread.interrupt() on the idle'd thread. Nothing happens. I am running out of ideas.
推荐答案
对该文件夹执行操作(从另一个线程进行)将导致 idle()
方法立即返回.因此,如果要强制中断它,只需从新线程调用 close()
.
Performing any operation on that folder (from another thread) will cause idle()
method to return immediately. So if you want to forcefully interrupt it, just call close()
from a new thread.
这篇关于如何中断IMAP的IDLE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!