In order to decrease server overload while searching,I’m going to provide delay for keyboard input.
use case:
1. user types symbols
2. if delay between typing symbols < 1 second,that search is NOT performed immediately and waiting when delay after last typed symbol is > 1second
3. if delay between typing symbols > 1 second,that search performed immediately
Is there best practises in JSE or in mobile Java(Blackberry)?
Looks like I should use TimerTask and Timer APIs for such case.Is it?
According to Java concurrency bible ‘Java concurrency in practice‘
Thus, I would do something like this example:
Note: I’m updating the status from a thread other than the EDT here which is illegal, but you get the idea.
EDIT: based upon great comments below (thanks!)
Timerwill work in this simple case, and it makes it easy to use a daemon thread (although it does have problems with tasks that throw exceptions, as described in the book). To do this replace above executor and listener as follows: