The process is the following:
Request to check for particular email message received is came. This email message should be added to the list of messages that are periodically checked for availability on mail server. Every 30 seconds another thread should search for messages from this list. If message is found it should be returned somehow to function that made request. If message isn't found during specified timeout period, exception should be thrown.
Note: I think that it may be quiet costly to create new thread every time new message appears. So I want to search for all messages from the list in one thread periodically.
How / with help of which classes I can implement it? (Javamail part is ready)