在Java中实现一个计时器事件的最简单方法 [英] Simplest way to implement a timer event in Java

查看:518
本文介绍了在Java中实现一个计时器事件的最简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林寻找一种方式,在Java SE 1.7实现一个计时器事件,我不想使用Swing计时器,因为我有这个应用程序到Android计划端口。

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.

背景

我写一个LoginSession类,应该产生一个事件时,会话超时 - 这个事件应该再由是SessionManager类进行处理。

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.

我$ P $此psume一个共同的足够需求 - 我期望会有这种内置支持简单的,但我似乎无法找到它。

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.

推荐答案

的简单的内置支持。使用<一个href=\"http://docs.oracle.com/javase/7/docs/api/java/util/Timer.html#schedule%28java.util.TimerTask,%20java.util.Date%29\"相对=nofollow> Timer.schedule()。

There is simple built-in support. Use Timer.schedule().

这篇关于在Java中实现一个计时器事件的最简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆