Starting a threadpool in a servlet container

后端 未结 5 887
野性不改
野性不改 2021-01-14 14:27

I have a servlet S which handles callbacks from a 3rd party site.

The callback invocations happen in a specific order. Thus, I need to queue them.

I propos

5条回答
  •  半阙折子戏
    2021-01-14 14:45

    Remember that while your servlets are in seperate threads, they're in the same VM instance, so they're living in a shared memory space. If you create a Singleton instance, it will automagically be shared by all the servlets. You can also create a separate servlet to act as your shared data, which has the advantage that you can use container services to persist it if you want.

    There's a thorough examination of ways of doing this --- technically called "servlet collaboration" --- in the OReilly book on servlet programming, available online here.

提交回复
热议问题