CallableImpl.java 504 B

1234567891011121314151617181920212223
  1. package course;
  2. import java.util.concurrent.Callable;
  3. /**
  4. * @author WanJl
  5. * @version 1.0
  6. * @title CallableImpl
  7. * @description
  8. * @create 2026/8/8
  9. */
  10. public class CallableImpl implements Callable<Integer> {
  11. @Override
  12. public Integer call() throws Exception {
  13. int sum=0;
  14. for (int i = 0; i < 100000; i++) {
  15. sum+=i;
  16. }
  17. String name = Thread.currentThread().getName();
  18. System.out.println(name+"---任务中-->"+sum);
  19. return sum;
  20. }
  21. }