java 异步调用 shell_Java 实现异步调用
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                java 异步调用 shell_Java 实现异步调用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                class1
public class MyExecutor {
private ExecutorService executor = Executors.newCachedThreadPool() ;
public void fun() throws Exception {
executor.submit(new Runnable(){
@override
public void run() {
try {
//要執行的業務代碼
Thread.sleep(10000);
System.out.print("----------");
}catch(Exception e) {
throw new RuntimeException("ERRO!");
}
}
});
}
}
class2
public class Demo{
public static void main(String[] args) {
MyExecutor? myExecutor = new MyExecutor();
try {
myExecutor.fun();
System.our.print("========");
}catch(Exception e) {
throw new RuntimeException("RUN_ERRO");
}
}
}
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的java 异步调用 shell_Java 实现异步调用的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: c语言将数据写不入文件,求大神看看为什么
- 下一篇: android source镜像源_【转
