マルチリニア、ハイコンカレント、非同期非ブロック実行


詳細

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;

public class Test {  
	  
    public static void main(String args[]) throws Exception {  
    	
    	//      
        long begin = System.currentTimeMillis();  
        //     10000 
        int count = 10000;  
         /**       */
        final List result = new Vector();
        final List lost_list = new Vector();  
          
        List list = new ArrayList();  
        for(int i=0;i>>    ,  :"+lost);  
        for(String s : lost_list){  
            System.out.println("lost:"+s);  
        }  
        System.out.println("    :"+(System.currentTimeMillis()-begin)+"  ");  
    }  
    
    /**         */
    public static final AtomicInteger COUNT = new AtomicInteger(0);  
    
    /**
     *      1
     * @return
     */
    public static final void getAndIncrement() {  
        while (true) {  
            int current = COUNT.get();  
            int next = current + 1;  
            if (COUNT.compareAndSet(current, next)) {  
                break;  
            }  
        }  
    }  
    
    /**      */
    public static final AtomicInteger SUCCESS_COUNT = new AtomicInteger(0);  
    
    /**
     *      1
     * @return
     */
    public static final void getSuccessAndIncrement() {  
        while (true) {  
            int current = SUCCESS_COUNT.get();  
            int next = current + 1;  
            if (SUCCESS_COUNT.compareAndSet(current, next)) {  
                break;  
            }  
        }  
    }  
    
}