controller異步處理

@RequestMapping(value = "/project",method = RequestMethod.GET)
public Callable<String> queryProjectApprovalInfo(){
    System.out.println("主線程開始:"+Thread.currentThread().getId());
    Callable<String> callable = new Callable<String>() {
        @Override
        public String call() throws Exception {
            System.out.println("子線程開始:"+Thread.currentThread().getId());
            String result = "執行結束";
            System.out.println("子線程結束:"+Thread.currentThread().getId());
            return result;
        }
    };
    System.out.println("主線程結束:"+Thread.currentThread().getId());
    return callable;
}
相關文章
相關標籤/搜索