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


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

Re: timer task(s) with parameters

From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: timer task(s) with parameters
Date 2017-05-31 07:50 +0200
Message-ID <ep73u0FnegkU1@mid.individual.net> (permalink)
References <ogjle5$1fq$1@gioia.aioe.org> <ogjmg5$49b$1@dont-email.me>

Show all headers | 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