Skip to main content

execute a method over a maximum period

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2010-04-01

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(,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