Skip to main content

execute a method over a maximum period

No replies
pedromarques
Offline
Joined: 2010-04-01
Points: 0

Good Afternoon in my time zone.

I am using the JavaMail api , and theres is a method in the Folder class called "search" that sometimes take too long to execute. What i want is to execute this method over a maximum period of time( say for example 15 seconds in maximum) , that way i am sure that this method will not run up more than 15 seconds.
Pseudo Code

messages = maximumMethod(Folder.search(),15);

Do i have to create a thread just to execute this methos and in the main thead use the wait method ?

Thanks very much