java.util.Timer:是否已弃用? [英] java.util.Timer: Is it deprecated?

查看:27
本文介绍了java.util.Timer:是否已弃用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了对这个答案的评论以及许多不推荐使用 java.util.Timer 的有关调度的其他问题(抱歉,没有参考).我真的希望不会,因为我将它用作在 Java 中安排事情的轻松方式(并且它运行良好).但如果它已被弃用,我会寻找其他地方.但是,快速浏览一下 API 文档 1.6不要说它被弃用了.它甚至没有在 Sun 的 弃用列表.

I read in a comment to this answer and in many other questions about scheduling (sorry, no references) that java.util.Timer is deprecated. I really hope not since I'm using it as the light way to schedule things in Java (and it works nicely). But if it's deprecated, I'll look elsewhere. However, a quick look at the API docs for 1.6 doesn't say anything about it being deprecated. It's not even mentioned in Sun's Deprecated List.

是否正式弃用*,如果是,我应该用什么代替?

Is it officially deprecated* and if so, what should I use instead?

* 另一方面,如果它没有被弃用,人们能不能停止对这个无辜且出色实现的 set-o-classes 的坏话?

* On the other hand, if it's not deprecated, could people stop badmouthing this innocent and brilliantly-implemented set-o-classes?

推荐答案

[JDK-8154799] 在 JDK 的错误跟踪器和 2016 年年中弃用 Timer 和 TimerTask JEP 277 表示 java.util.Timer(和 TimerTask)将在 JDK 9 中被弃用.

There is [JDK-8154799] deprecate Timer and TimerTask in the JDK’s bug tracker and in mid-2016 JEP 277 stated that java.util.Timer (and TimerTask) would be deprecated in JDK 9.

一些 Java SE API 将添加 @Deprecated 注释,更新,或删除.下面列出了此类更改的一些示例.

Several Java SE APIs will have a @Deprecated annotation added, updated, or removed. Some examples of such changes are listed below.

[…]

  • 将@Deprecated 添加到 java.util.TimerTimerTask

但是,在 JDK 9 版本中,这些类并未被弃用(已弃用的类可以在 弃用列表).

However, in the JDK 9 release, those classes are not deprecated (deprecated classes can be found in the Deprecated List).

这篇关于java.util.Timer:是否已弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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