Well, as always, it depends ;-)

You might say that contract is used as a local variable and will never be
accessed by 2 threads at the same time.
However, several threads might use it:
- If you store contracts in the "application"
- If you store the contract in the session!!!
- If you start using object caches (factory or singleton stuff).

You don't know whether you'll do this later (maybe you also use Contract in
a totally different application). So it looks safer to synchronize. Don't
synch in the JSP!!!! S
Synch your add update and delete methods.

The overhead of synchronization is much lower than it used to be.

Geert Van Damme

> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of chintha ratnasiri
> Sent: woensdag 30 mei 2001 0:48
> To: [EMAIL PROTECTED]
> Subject:
>
>
> Hi,
> I am developing a multi - user application using jsp, some java
> classes(eg.Contract) which I  have in a package and import into the jsp
> page. Contract has methods for adding, updating, deleting  etc.
> This is how I use this class in my jsp page.
>
> <% Contract mycontract = new Contract();
>    mycontract.add(myobject);
> %>
>
> I have not declared these methods as static, nor do I have any static
> variables within these java classes. All methods  are public and variables
> are  private to method or class.
>
> My question is :
> 1. Do I have to declare my add , update methods as synchronized
> in Contract
> class?
>
> 2.Do I have to synchronize the block where it is called in the
> jsp page? Or
> synchronize them both to prevent concurrency problems?
>
> I am not clear about this. I hope someone out there can help me with my
> query. Many thanks for any hints.
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
>
> ==================================================================
> =========
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set
> JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to