Hi Liam,

Declare the method in the ServiceLayerServlet as synchronized to ensure it
is thread safe. There are some performance issues though - can cause a
bottleneck under heavy load.

Lindsay.

> -----Original Message-----
> From: Liam Dens [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, February 01, 2000 2:01 AM
> Subject:      static methods
>
> Hi all
>
> Given the scenario below will it be safe?
>
> A servlet needs to create objects on the fly, to do this it will access a
> 'service layer' that will create the required object and then return it.
>
> The method in the ServiceLayerServlet is static because it uses the
> Class.forName() call. This method is accessed in the calling servlet, from
> the doGet() method like so:
>
>    Object obj = (Object) ServiceLayerServlet.getObject(theClassName);
>
> So the question is - The call to ServiceLayerServlet is in the doGet(),
> this should be thread safe - yes?
>
> Thanks in advance people.

___________________________________________________________________________
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