---
title: "Spring中多个线程同时访问一个单例类的问题"
author: "ycysth"
date: "2010-04-16T22:17:07Z"
tags: ["Bean", "Spring", "prototype"]
categories: ["企业架构"]
slug: "spring"
draft: false
lastmod: "2010-04-16T22:18:29Z"
id: 645914
url: "https://ycysth.iteye.com/blog/645914"
---

Spring默认的类都为单例的，在多个线程同时访问该类并存在成员变量的时候，很可能会造成数据的不同步,以后使用需要注意，遇到要么不用成员变量，要么把该Bean的scope属性设置成prototype.