package privateclass;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

//我们可以自己给一个集合加上锁让他变成安全的
public class Mycollections
{
	public static List syncList(List list)
	{
		return new Mylist(list);
	}

	private static class Mylist implements List
	{
		private List list;
		Mylist(List list)
		{
			this.list = list;
		}
		Object Lock = new Object();
		@Override

		public int size() {
			synchronized(Lock)
			{
				return list.size();
			}
			// TODO Auto-generated method stub
		}

		@Override
		public boolean isEmpty() {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean contains(Object o) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public Iterator iterator() {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public Object[] toArray() {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public Object[] toArray(Object[] a) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public boolean add(Object e) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean remove(Object o) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean containsAll(Collection c) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean addAll(Collection c) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean addAll(int index, Collection c) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean removeAll(Collection c) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean retainAll(Collection c) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public void clear() {
			// TODO Auto-generated method stub

		}

		@Override
		public Object get(int index) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public Object set(int index, Object element) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public void add(int index, Object element) {
			// TODO Auto-generated method stub

		}

		@Override
		public Object remove(int index) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public int indexOf(Object o) {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public int lastIndexOf(Object o) {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public ListIterator listIterator() {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public ListIterator listIterator(int index) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public List subList(int fromIndex, int toIndex) {
			// TODO Auto-generated method stub
			return null;
		}

	}
}

  

01-03 06:16