I use JavaMail API, and there is a method in the Folder class called "search", which sometimes takes too long to complete. I want this method to run for a maximum period of time (for example, a maximum of 15 seconds), so I'm sure this method will not work for more than 15 seconds.
Pseudo code
messages = maximumMethod(Folder.search(),15);
Is it necessary to create a thread only to execute this method, and the wait method in the main thread?
tt0686 source
share