我也是头一回听说java会破坏数据结构,这是jvm要保证的事情,如果真有问题也是该给jvm提这个bug的,怎么也会以为java像c/c++那样吗,对一个内存地址,指定不同的数据类型会取得怪异的数据,或者偏移了一个字节数据又是怪怪的吗?在java中不会的.

The singleton usage in Webapplication is fishy issue.
That is why people love EJB container then multithread problem is screened off by container.

but if with Spring, you must pay 100% attention how to use singleton. because it is not thread-safe.

You must use Thread-local to avoid this problem.

OO is important but here people make it as God,even having the religious passion on it. The real architecture needs more than OO.
In most of the situation, design pattern cannot fit the real situation. dont use pattern for creating pattern.

The only persists methodology is thought of the engineering.

看看HashMap的put方法的实现.
public V put(K key, V value) {
if (key == null)
return putForNullKey(value);
int hash = hash(key.hashCode());
int i = indexFor(hash, table.length);
for (Entry<K,V> e = table; e != null; e = e.next) {
Object k;
if (e.hash == hash && ((k = e.key) == key || key.equals(k))) {
V oldValue = e.value;
e.value = value;
e.recordAccess(this);
return oldValue;
}
}

modCount++;
addEntry(hash, key, value, i);
return null;
}

你当真敢说在多线程序情况下不同步 不会出现数据混乱,HashMap实例不会出现不可预计的异常,

如果你还坚持,那我问你HashMap与HashTable还有什么区别?

HashTable的put方法如下:
public synchronized V put(K key, V value) {
// Make sure the value is not null
if (value == null) {
throw new NullPointerException();
}

// Makes sure the key is not already in the hashtable.
Entry tab[] = table;
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
for (Entry<K,V> e = tab[index] ; e != null ; e = e.next) {
if ((e.hash == hash) && e.key.equals(key)) {
V old = e.value;
e.value = value;
return old;
}
}

一直很狠的说,可是 是不是需要调查一下,你印在脑子里的知道真的对吗?

mark

前辈们,这么多年过去了,现在小弟也说下,HashMap有漏洞的,会出现相同的key,小弟确实写过这样的例子