• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Refresh
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Refresh


  • Subject: Re: Refresh
  • From: "Jerry W. Walker" <email@hidden>
  • Date: Tue, 27 Feb 2007 10:42:47 -0500

Hi, Florijan,

The WOApplication class is a singleton for any WebObjects application. From the first paragraph of the JavaDoc on WOApplication:

     The primary role of the WOApplication class is to coordinate the
     handling of HTTP requests. Each application must have exactly
     one WOApplication object. The application object receives...

Honestly, I've never considered the possibility that a static variable declared for a class in one application is shared with any other application using that same class within the same Java Virtual Machine. I don't think this is true, and if it is, there are a few things about static variables that I will have to rethink before this bites me. Whether true or not, the variable wouldn't be shared between JVM's.

That's why Robert Walker was suggesting scheduling outside the application.

So... has anyone any information on static variables in a class shared between separate applications on the JVM if two applications use that same class?

Regards,
Jerry

On Feb 27, 2007, at 10:02 AM, Florijan Stamenkovic wrote:

Hi all,


What I always had trouble with when attempting to use timers is the problem it creates when running multiple instances of your application.

I don't see why that would be a problem, if a Timer is static. Initialize it once, and never worry about it again.


If you use a timer inside your WO application instance, and you have more than one instance of your application running, then you will have more than one timer running possibly updating your file more often than you really want.

It may be possible to configure your timer to run on only one instance, say instance number 1. The problem here is that if instance 1 is shutdown then no timer will be running even if their are other instances available.

Static comes in handy here. Instances shut down, timer keeps running. Just make sure that you make a timer whose execution thread is a daemon. Otherwise it keeps running and running and running....


Using an outside scheduler solves these issues in a clean and effective way.

Yeah, kind of nice.

As an extension to this method I often run the process in a separate thread, for those actions that may take more than a few seconds to execute.

I would probably stick to a static Thread in the Application class anyway, that is started with the first instance. Nice and simple. Timer in my eyes only becomes handy if you need to schedule a lot of different tasks at different intervals.


My two cents,
Flor
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden


--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial Strength Internet Enabled Systems


    email@hidden
    203 278-4085        office



_______________________________________________
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


  • Follow-Ups:
    • Static in WO (was: Refresh)
      • From: Florijan Stamenkovic <email@hidden>
    • Re: Refresh
      • From: Mark Ritchie <email@hidden>
References: 
 >Refresh (From: WIESEN Bruno <email@hidden>)
 >Re: Refresh (From: Zak Burke <email@hidden>)
 >Re: Refresh (From: Robert Walker <email@hidden>)
 >Re: Refresh (From: Florijan Stamenkovic <email@hidden>)

  • Prev by Date: Re: New WOnderApplication won't start
  • Next by Date: Javamonitor help
  • Previous by thread: Re: Refresh
  • Next by thread: Re: Refresh
  • Index(es):
    • Date
    • Thread