aspose file tools*
The moose likes Servlets and the fly likes Global Var.  sync issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Global Var.  sync issue" Watch "Global Var.  sync issue" New topic
Author

Global Var. sync issue

sean cee
Ranch Hand

Joined: Oct 24, 2000
Posts: 115
Hi all,
with my servlet application, I need to make use of application variable.
Each request for the servlet will need an access to application variable and add some data to application var. and store back.
but what if two requests were made at the same time? Can this be an issue like in Java Multithreaded application ?
or does servelt engine handle this?
Thanks in advance

Sean <br />SCJP2, SCJP2p1.4, SCWCD
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Yes, access by two threads at the same time can be a problem. Just synchronize access to the variable.
------------------
Bosun
SCJP for the Java� 2 Platform


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
Originally posted by Bosun Bello:
Yes, access by two threads at the same time can be a problem. Just synchronize access to the variable.

Is this dependent on the server? I mean I can understand that Tomcat requires it, but I would have thought the Weblogic would take care of it for the Application object.
Adam


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

Why should it be? Multithreading support as a means is a core component of Java. EJBs have their innards protected -- from EXTERNAL synchronization issues -- as part of the remoting process, but servlets are just classes and they are quite capable of being managed by the much lighter weight facilities that are built into Java.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Global Var. sync issue