标签:imp main 返回结果 sys catch rgs AC ati current
Callable接口类似于Runnable,但是Runnable不会返回结果,并且无法抛出返回结果的异常,而Callable可以
package com.wjz.demo; import java.util.concurrent.Callable; public class CallableDemo { public static void main(String[] args) { try { Callable<String> call = new Callable<String>() { @Override public String call() throws Exception { return "hello world!"; } }; System.out.println(call.call()); Runnable run = new Runnable() { @Override public void run() { System.out.println("hello world!"); } }; run.run(); } catch (Exception e) { // } } }
标签:imp main 返回结果 sys catch rgs AC ati current
原文地址:https://www.cnblogs.com/BINGJJFLY/p/9072628.html