Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #36667

Re: timer task(s) with parameters

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: timer task(s) with parameters
Date Wed, 31 May 2017 07:50:55 +0200
Lines 29
Message-ID <ep73u0FnegkU1@mid.individual.net> (permalink)
References <ogjle5$1fq$1@gioia.aioe.org> <ogjmg5$49b$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net W2KepKsoUKPEDtgTx2MMTQewIET6H9mJ+mw9511cuJZGBzN8g=
Cancel-Lock sha1:D7RJWeCO5FuyWHg+OrHAS3oX+EA=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1
In-Reply-To <ogjmg5$49b$1@dont-email.me>
Content-Language en-US
Xref csiph.com comp.lang.java.programmer:36667

Show key headers only | View raw


On 30.05.2017 13:57, Eric Sosman wrote:

>      (Note: I have not examined the rest of your code carefully;
> there might be other problems, too.)

A few observations:

For both recurring tasks one Timer instance is created.  Normally the 
approach would be to just use one Timer instance - especially since 
tasks do not seem to be very heavy.

Your use of variable declarations is very C-ish.  Don't do that in Java. 
  Rather declare them for the smallest necessary scope.  This helps 
avoid one class of errors.

format1 can be made final, as well as calendar and timer (when using one 
Timer only).

Even for such a simple example you could factor out the common part of 
both scheduling activities and thus make it more readable.  Getting into 
that habit will help you create more modular and less redundant code.

Kind regards

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

timer task(s) with parameters newsgroups <pippo.pluto@disney.com> - 2017-05-30 13:35 +0200
  Re: timer task(s) with parameters Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-05-30 07:57 -0400
    Re: timer task(s) with parameters newsgroups <pippo.pluto@disney.com> - 2017-05-30 14:05 +0200
    Re: timer task(s) with parameters Robert Klemme <shortcutter@googlemail.com> - 2017-05-31 07:50 +0200

csiph-web