Demo01.java 743 B

12345678910111213141516171819202122232425262728
  1. package J20250731.demo02_join;
  2. /**
  3. * @author WanJl
  4. * @version 1.0
  5. * @title Demo01
  6. * @description
  7. * @create 2025/7/31
  8. */
  9. public class Demo01 {
  10. public static void main(String[] args) throws InterruptedException {
  11. Thread t1 = new Thread(() -> {
  12. for (int i = 0; i < 1000; i++) {
  13. String name = Thread.currentThread().getName();
  14. System.out.println(name + "->" + i);
  15. }
  16. });
  17. Thread t2 = new Thread(() -> {
  18. for (int i = 0; i < 1000; i++) {
  19. String name = Thread.currentThread().getName();
  20. System.out.println(name + "->" + i);
  21. }
  22. });
  23. t1.start();
  24. t2.start();
  25. t1.join();
  26. }
  27. }