Simplest way to implement a timer event in Java

独自空忆成欢 提交于 2019-12-11 04:16:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!