Java – how to interrupt the idle of IMAP?

I'm using the JavaMail API that connects to my IMAP server Using javax mail. Folder. When idle () method, everything works well My listener is called when a new message is received But the question is always a free block. How can I interrupt it? How to actually stop listening without killing a java program?

I tried calling thread on an idle'd thread interrupt(). Nothing happened I'm running out of ideas

Solution

Any operation on the folder (from another thread) will cause the idle () method to return immediately Therefore, if you want to force it to break, just call close () from the new thread

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>