oh, what is the answer to my questions if a() and b() are in 2 classes?
(actually, I put them into 2 servlets)
thanks!
xz
Hemendra Rana wrote:
>
> If a() and b() are methods in the same class, no two threads will be able to
> execute them at the same time.
>
> Xizhen Wang wrote:
>
> > Hi! ALL, I have a question regarding synchronization in Java when I
> > write servlet.
> >
> > public synchronized void a(){
> > String table_name = "user";
> > access_db(table_name); //access table "user" in database DB
> > }
> >
> > public synchronized void b(){
> > String table_name = "user";
> > access_db(table_name); //access table "user" in database DB
> > }
> >
> > private void access_db(String db_table_name) {
> > ......
> > }
> >
> > I think method a and b can go into access_db at the same time since they
> > are 2 distinct methods. right? so, that means they are not really
> > synchronized at the program level. So, I am wondering if the database
> > (Oracle for example) can synchronized the accesses itself automatically.
> > if so, can the database administrator control the level of
> > synchronization (database, table or the record level)? Also, do method a
> > and b really need to be synchronized if the database can synchronize
> > itself?
> >
> > I am puzzled.. Can anyone help?
> >
> > thanks!
> >
> > Unsubscription, archives, FAQ - http://www.xcf.berkeley.edu/lists.html
___________________________________________________________________________
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