users@glassfish.java.net

Re: Bug? <max-pool-size> seems to count only idle EJB instances

From: <glassfish_at_javadesktop.org>
Date: Tue, 01 Dec 2009 11:22:43 PST

The INSTANCE trick defeats the thread-safeness of JEE.

I think you will find that if you implement business function like this:

private int mustAlwaysBeZeroOrOne = 0;
public void myBusinessMethod() {
        mustAlwaysBeZeroOrOne++;
        System.out.println("The variable is: " + mustAlwaysBeZeroOrOne);
        Thread.sleep(5000L);
        mustAlwaysBeZeroOrOne--;
}

You will find that if you use your bean, through getInstance() trick, you will find that mustAlwaysBeZeroOrOne will increment up to the number of simultaneously running client threads.

I.e. not thread safe.

Thanks
Jacob
[Message sent by forum member 'jablo' ]

http://forums.java.net/jive/thread.jspa?messageID=374145