@GetMapping("/demo")
public String demo() {
new Thread(() -> {System.out.println("1.栀子花开");}).start();
new Thread(() -> {System.out.println("2.牛郎和织女");}).start();
new Thread(() -> {System.out.println("3.君子好球");}).start();
new Thread(() -> {System.out.println("4.好雨知时节");}).start();
System.out.println("End");
return "rock service";
}
返回结果:
1.栀子花开
2.牛郎和织女
3.君子好球
End
4.好雨知时节
总结:多线程执行过程中的先后完全由CPU掌控