The singleton mode is inevitably accompanied by multi-threading problems. You can use appropriate locking mechanisms to control it, or ThreadLocal is also a solution. Specific problems should be analyzed in detail. Of course, if it is a stateless class, you don’t need to think so much.
The singleton mode is inevitably accompanied by multi-threading problems. You can use appropriate locking mechanisms to control it, or
ThreadLocal
is also a solution. Specific problems should be analyzed in detail. Of course, if it is a stateless class, you don’t need to think so much.