Thanks charles, i think in my earlier mail it should have been
"synchronized" instead of "static".  I stand corrected.

Cheers
Srini

-----Original Message-----
From: Charles Chen [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 10, 2000 2:03 PM
To: [EMAIL PROTECTED]
Subject: Re: Synchronize method in the servlet [Scanned by Yellow Pages
PostMaster]


Contact:   Tel: 2726  -  New Media Systems, 1st Floor South, Queens Walk


Static variables are class variables that means for each class, there will
be
only one static variable instance shared by all the instances of that class.
It
DOES NOT mean that only one instance can access it at one time. Therefore,
static variables are not directly related to database locking. Meaning, it
does
not matter if you are using static variable or not.

To lock, you either synchronize the method that does the update to the
database,
or you can simply reply on the native database locking mechanism. All
databases
provide such locking mechanism one way or another. If you are using Oracle,
for
instance, you can lock the row you are updating by select it for update.
Once it
is locked, no other process (thread) can ever make any update or
modification to
that row. This way, you don't have to do anything in your Java codes. When
the
row is locked by one thread, all other threads will smiply wait until
timeout
and report an error.



Charles





"Srini Sathya." <[EMAIL PROTECTED]> on 10/10/2000 12:22:04 PM

To:        [EMAIL PROTECTED]
cc:         (bcc: Charles Chen/YellowPages)
From:      "Srini Sathya." <[EMAIL PROTECTED]>, 10 October 2000,
12:22
           p.m.

Re: Synchronize method in the servlet  [Scanned by Yellow Pages PostMaster]


would the DB's will not have an internal lock for their operations??.  is it
mandatory to make the DB object static for DB operations.

For example in an online reservation system if you have only one ticket left
and 2 users are trying to reserve at the same milliseconds i believe DB will
not entertain both of their request.  Am i right??.

Cheers
Srini

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to