如题,看网上很多人都说这个类是线程安全的,但我看了jdk1.6 的源码,并没有发现这类的线程安全机制,这个类到底是不是安全的,如果是的话,安全机制如何实现的?
[code="java"]
public synchronized int size() {
public synchronized boolean isEmpty() {
public synchronized boolean contains(Object value) {
public synchronized Enumeration<K> keys() {
public synchronized V get(Object key) {
public synchronized V put(K key, V value) {
public synchronized V remove(Object key) {
public synchronized void putAll(Map<? extends K, ? extends V> t) {
public synchronized void clear() {
public synchronized Object clone() {
public synchronized String toString() {
private transient volatile Set<K> keySet = null;
private transient volatile Set<Map.Entry<K,V>> entrySet = null;
private transient volatile Collection<V> values = null;
public Set<Map.Entry<K,V>> entrySet() {
if (entrySet==null)
entrySet = Collections.synchronizedSet(new EntrySet(), this);
return entrySet;
}
[/code]
你再自己去查一下 synchronized,volatile,Collections.synchronizedSet 的用法吧。
你确定hashtable包在com.sun.org.apache.xalan.internal.xsltc.runtime;下面吗