AW: AW: WOTimer problem
AW: AW: WOTimer problem
- Subject: AW: AW: WOTimer problem
- From: Helge Staedtler <email@hidden>
- Date: Sun, 18 Sep 2005 14:44:44 +0200
nice solution david.
It's based on a java.util.TimerThread - so as I said: use a thread - you
could have pointed this out.
sometimes it is not a bad idea to do things differently and i.e. on your
own; e.g. if you want independence for your own solution from any other
framework which will pay off as longtime-stability of your solution wether
or not the underlying framework changes. And at the same time you will
perhaps be able to write a methodcall which is convenient not only for
machines but also for humans e.g. to write "10" instead of "10 * 1000" to
start something in 10 seconds. no one (of approx. 80% of developers) needs a
precision of milliseconds to schedule a timer in everydaywork.
this way you also gain productivity of your once invented own timer-class,
because you do not need to try to understand the weird API of milliseconds
and the complicated method-signature again.
I do like to do things which increase the overall productivity, flexibility,
art & style and innovation of my code by optimizing things (also threads and
other java-stuff) using the principle of pareto
(http://en.wikipedia.org/wiki/Pareto_principle). If I need to do something
on my own to reach these goals I will do it alone. If I can reach better
results in a team I will do it in a team.
I think everyone has a right to a different solution - its like the freedom
of speech and artistic freedom. it is an illusion, that there exists ONLY
ONE BEST WAY of doing coding/software-development. this is clearly not the
case. even if many things in coding are similar to mathematical/physical
principles, there is plenty of room for creativity here. it is basically why
I love to build high quality code, because of the possible diversity. sure I
could take 4 wheels and an engine put together as an automobile. but why the
hell do there exist so many different variants of them? perhaps because
there does not exist the ONE BEST solution.
I think it is in a way a very ignorant (and antagonistic) point of view to
abandon diversity (which is what david implicitly expressed). diversity is
an important value which also is paying off in the IT industry. diversity
brings you stability (think about the M$-monopoly and viruses) and it brings
you ideas for new innovation. diversity is the base for competition (think
about mother nature); competition for the BETTER solution not the BEST
solution is also called life. it depends on the person you ask what each
person thinks is the BEST solution for a specific problem especially if you
ask computer programmers.
the point I wanted to make with WOTimer was to just shed some light on it as
a way to handle timed tasks. I have made bad experiences with WOTimer if I
even used more than one scheduled WOTimer-events (because they are not
running in real threads as it seems) and therefore I write it on this list.
If someone does not know how to write a thread on his own he/she is welcome
to drop me a mail.
regards,
helge
Am 17.09.2005 10:15 Uhr schrieb "David Teran" unter
<email@hidden>:
> I know Helge really likes to do things on his own (writing an own
> thread instead, sorry, could not resist ;-) but in this case there is
> a simple solution:
>
> Just look at the java.lang.Timer and the java.lang.TimerTask classes,
> here is a simple quick example:
>
> Timer t = new Timer();
> TimerTask tt = new TimerTask() {
>
> public long scheduledExecutionTime() {
> return super.scheduledExecutionTime();
> }
>
> public void run() {
> doSomething();
> t.schedule(tt, 1000 * 10);
> }
>
> public boolean cancel() {
> return super.cancel();
> }
>
> };
> t.schedule(tt, 1000 * 10); // start the task in 10 seconds
>
>
> TimerTask is an abstract class, you can instanciate an object without
> creating a subclass like showed in the example. In the run method you
> should do whatever you want.
>
> regards, David
>
> On 16.09.2005, at 22:41, Helge Staedtler wrote:
>
>> I can only give you one advice:
>>
>> do not use WOTimer!!
>>
>> it will consume very much of your processortime if you use it
>> excessively
>> and at the same time the fireing is not any longer predictive! It
>> seems that
>> WOTimer is running at a very very low priority and that the
>> timepoints to
>> fire are only checced occasionally. this is at least my experience.
>> write your own thread instead. that way you will be happier!
>>
>> regards,
>> helge
>>
>>
>>
>> Am 16.09.2005 18:57 Uhr schrieb "Miguel Arroz" unter
>> <email@hidden>:
>>
>>
>>> Hi!
>>>
>>> I have the following method:
>>>
>>> public void timerMethod() {
>>> this.doSomething();
>>> WOTimer.scheduledTimer( 5 * 1000,
>>> this,
>>> "timerMethod",
>>> null,
>>> null,
>>> false);
>>>
>>> }
>>>
>>> I setup the timer using WOTimer.scheduledTimer( 10 * 1000, // 10
>>> seconds from app startup
>>> mailSender,
>>> "timerMethod",
>>> null,
>>> null,
>>> false);
>>>
>>> After 10 seconds, the timer fires itself and my method is executed
>>> and this.doSomething() run. The problem is that, after 5 seconds,
>>> nothing happens. The timer is not rescheduled again. What's
>>> happening?
>>>
>>> BTW, I don't want to use the repeat flag, because I want the time
>>> (in this sample, 5 seconds) to start counting AFTER this.doSomething
>>> finishes, and not before.
>>>
>>> Yours
>>>
>>> Miguel Arroz
>>>
>>>
>>> "GUERRA E' PAZ
>>> LIBERDADE E' ESCRAVIDAO
>>> IGNORANCIA E' FORCA" -- 1984
>>>
>>> Miguel Arroz
>>> http://www.ipragma.com
>>>
>>>
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>>
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> 40cluster9.com
>>
>> This email sent to email@hidden
>>
>>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden