views:

200

answers:

1

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?

I've tried calling Thread.interrupt() on the idle'd thread. Nothing happens. I am running out of ideas.

+1  A: 

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.

ChssPly76