자바 다 중 스 레 드 비 즈 니스 논리 처리 간단 한 패키지

           https://github.com/vbvbipny/multhread
                     ,                 ,           ,              ,         。    ,      
       ,       


1.                 ,      


    :

/**
 * Created with IntelliJ IDEA.
 *          
 * className: TaskMulThreadServiceTest
 *
 * @version 1.0
 *          Date Time: a
 *@author: ddys
 */
public class TaskMulThreadServiceTest extends TestCase implements ITaskHandle<String,Boolean>{

    public void testExecute() throws Exception {
        String [] taskItems = new String[100];
        for (int i=0;i<100;i++){
            taskItems[i]="  "+i;
        }
        IMulThreadService<String,Boolean> mulThreadService = new TaskMulThreadService(this);
        long start = System.currentTimeMillis();
        List<Boolean> result = mulThreadService.execute(taskItems);
        for (Boolean e : result){
            if(!e){
                System.out.println("      ");
            }
        }
        System.out.println("        ,  "+(System.currentTimeMillis()-start)+",     "+result.size());
    }

    /**
     * Created with IntelliJ IDEA.
     *     ,         
     * className: TaskMulThreadService
     *
     * @author: ddys
     * @version 1.0
     * Date Time:
     */
    public Boolean execute(String s) {
        System.out.println(Thread.currentThread().getId()+"      "+s);
        return true;
    }
}
2.           ,                 ,          


    :
/**
 * Created with IntelliJ IDEA.
 *                
 * className: SelectTaskMulThreadServiceTest
 *
 * @version 1.0
 *          Date Time: a
 *@author: XWK
 */
public class SelectTaskMulThreadServiceTest extends TestCase implements ISelectTask<String,Boolean>{

    public void testExecute() throws Exception {
        IMulThreadService<String,Boolean> mulThreadService = new SelectTaskMulThreadService(this);
        long start = System.currentTimeMillis();
        List<Boolean> result = mulThreadService.execute();
        for (Boolean e : result){
            if(!e){
                System.out.println("      ");
            }
        }
        System.out.println("        ,  "+(System.currentTimeMillis()-start)+",     "+result.size());
    }
    /**
     * Created with IntelliJ IDEA.
     *     ,         
     * className: TaskMulThreadService
     *
     * @author: ddys
     * @version 1.0
     * Date Time:
     */
    public Boolean execute(String s) {
        System.out.println(Thread.currentThread().getId()+"      "+s);
        return true;
    }

    /**
     * @param 'a     
     * @return a    
     * @throws
     * @Title: a
     * @Description:       
     * @author ddys
     * @date 2015-11-15 21:09
     */
    public String[] getTaskItem() {
        String [] taskItems = new String[100];
        for (int i=0;i<100;i++){
            taskItems[i]="  "+i;
        }
        return taskItems;
    }
}

좋은 웹페이지 즐겨찾기