java呼び出しの非同期方法

1103 ワード

                        ,                (       )      。                 :
          
        /**
	 *     
	 */
	public void doJob() {
		Map jsonBean = new LinkedHashMap();
		if (!UtilTools.isEmpty(token)&& token.equals("4297f44b13955235245b2497399d7a93")) {
                       //      
                       try {
				ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
				cachedThreadPool.execute(new Runnable() {
					 
				    public void run() {
				    	
						// do task
						todoUsp();
				    }
				});
				cachedThreadPool.shutdown();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

			jsonBean.put("success", "true");
		} else {
			jsonBean.put("success", "false");
		}


		this.renderJson(UtilTools.encodeObject2Json(jsonBean));
	}
        
        /*         */
        public void toDoUsp(){

            //      
            ...
        }


       Ajax      ,      ,                      。