Thread Safety of ServletContext objects

后端 未结 5 1483
余生分开走
余生分开走 2020-12-06 13:15

I am storing a HashMap object in my ServletContext. But Multiple Request thread are reading and Modifying this HashMap.

As i belive the ServletContext objects are sh

5条回答
  •  星月不相逢
    2020-12-06 13:18

    You need to synchronize your ServletContext object. for eg:-

    synchronized(ctx){
     //your code here
    }
    

提交回复
热议问题