Concurrent access to static methods

前端 未结 6 1877
面向向阳花
面向向阳花 2020-12-14 01:45

I have a static method with the following signature:

public static List processRequest(RequestObject req){
  // process the request obje         


        
6条回答
  •  没有蜡笔的小新
    2020-12-14 02:40

    All your calls to the method will be executed concurrently... but:

    You may have concurrency issue (and being in non thread-safe situation) as soon as the code of your static method modify static variables. And in this case, you can declare your method as synchronized

    If your method only use local variables you won't have concurrency issues.

提交回复
热议问题