• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Global Var. sync issue

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic