zoukankan      html  css  js  c++  java
  • list类里面的东西加锁 (手动加锁方法)

    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;
    		}
    		
    	}
    }
    

      

  • 相关阅读:
    通过GUID生成可持久化的PID
    使用redisTemplate存储数据,出现xACxEDx00x05tx00
    二分查找法c语言实现
    请求路径@PathVariable注释中有点.英文句号的问题(忽略英文句号后面的后缀)
    windows下根据tcp端口查询对应的进程id(端口被占用)
    解决gradle项目每次编译都下载gradle-x.x-all.zip gradle-x.x-bin.zip
    HideTcpip.c
    ANSI C遍历二维数组指针地址
    sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    centos7安装VuePress
  • 原文地址:https://www.cnblogs.com/WINDZLY/p/11788682.html
Copyright © 2011-2022 走看看