问题
Im looking for a way to implement a timer event in Java SE 1.7, I don't want to use Swing timers as I have plans to port this application to Android.
Background
Im writing a LoginSession class that should generate an event when the session times out - this event should then be handled by a SessionManager class.
I presume this a common enough requirement -I would expect there be a simple built in support for this but I can't seem to find it.
回答1:
There is simple built-in support. Use Timer.schedule().
来源:https://stackoverflow.com/questions/12641957/simplest-way-to-implement-a-timer-event-in-java