At 06:02 PM 7/20/99 +0200, you wrote:
>
>Hi Christopher,
>On Tue, 20 Jul 1999, Christopher T. Beers wrote:
>CTB| I appreciate everyone help in this matter yesterday. The porblem
>CTB| was the scope of my doPost() method. Outside of the method I declare
>CTB|
>CTB| private Hashtable table = new Hashtable();
>
>You should never do this, because the doPost(), doGet() or
>service()-Method could be called from several threads _in parallel_ which
>means that your parameters could get munged if two peope connect to your
>servlet. You've to make sure that your methods are reentrant.
>
>In order to get this save, initialize your Hashtable in the processing
>method:
>
> public void doPost (...) {
> Hashtable table = new Hashtable();
> .. do stuff
> }
>
>If you need these parameters in other methods in your servlet (which is
>what I assume you want do), you've to pass the table as parameter .. no
>way around it ..
Yes there is, just put the usage in a synchronized block:
synchronized ( table ) {
....
table.put( obj );
...
}
- Claude
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
READ THE FAQ!!!! <http://java.apache.org/faq/>
Archives and Other: <http://java.apache.org/main/mail.html/>
Problems?: [EMAIL PROTECTED]