avatar
Timer and TimerTask# Java - 爪哇娇娃
p*p
1
There is lots of timer taskes in my software, such as session time out, auto-
reload and clean.... I use TimerTask.run and Timer.schedule(...) to implement
them.
In order to save rescoure, I use a single Timer for all such taskes in my
Application(somehow as a static). My question is, could it be a performance
hit when tousand such taskes running on single Timer, or i'd better use more
timers.
avatar
c*n
2

-
implement
From the Timer() class:
Implementation note: This class scales to large numbers of concurrently
scheduled tasks (thousands should present no problem). Internally, it uses a
binary heap to represent its task queue, so the cost to schedule a task is O(
log n), where n is the number of concurrently scheduled tasks.

【在 p***p 的大作中提到】
: There is lots of timer taskes in my software, such as session time out, auto-
: reload and clean.... I use TimerTask.run and Timer.schedule(...) to implement
: them.
: In order to save rescoure, I use a single Timer for all such taskes in my
: Application(somehow as a static). My question is, could it be a performance
: hit when tousand such taskes running on single Timer, or i'd better use more
: timers.

avatar
p*p
3
Thanx, so the summery is?

(

【在 c*****n 的大作中提到】
:
: -
: implement
: From the Timer() class:
: Implementation note: This class scales to large numbers of concurrently
: scheduled tasks (thousands should present no problem). Internally, it uses a
: binary heap to represent its task queue, so the cost to schedule a task is O(
: log n), where n is the number of concurrently scheduled tasks.

avatar
c*t
4
Summary is that Sun's implementation is a great one. Don't bother to create
your own.

【在 p***p 的大作中提到】
: Thanx, so the summery is?
:
: (

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。