add recursive path find demo

add demo for creating new thred
This commit is contained in:
2025-02-17 09:35:24 +08:00
parent 3c709917e1
commit f5472740be
6 changed files with 160 additions and 0 deletions

View File

@ -0,0 +1,22 @@
package createthread;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
public class CreateByCallable implements Callable<String> {
@Override
public String call() throws Exception {
return "create by implementing Callable";
}
public static void main(String[] args) {
CreateByCallable createByCallable = new CreateByCallable();
FutureTask<String> futureTask = new FutureTask<>(createByCallable);
new Thread(futureTask).start();
try {
System.out.println(futureTask.get());
} catch (Exception e) {
e.printStackTrace();
}
}
}