怎么理解这句话:spring的bean都是单实例(singleton)的,其最大好处就是线程无关性? 我觉得如果是单实例的,那么对于某个bean,在spring容器中应该全局就一个bean实例。如果只有一个bean实例,多个线程都用它,才更会产生线程的冲突啊!
巴扎黑2017-04-18 09:45:46
Thread-independent means that each thread will not be allocated an instance, or the generation of instances has nothing to do with threads. But thread independence does not mean thread safety. Thread safety needs to be done by yourself
ringa_lee2017-04-18 09:45:46
Single instance beans are all stateless, so why do thread conflicts arise? If you use a stateful bean as a single instance, there is something wrong with your own logic