Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing TtlRunnable.get #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/main/java/org/example/controller/DemoController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.example.controller;

import com.alibaba.ttl.TransmittableThreadLocal;
import com.alibaba.ttl.TtlRunnable;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -20,19 +21,13 @@ public class DemoController {

@GetMapping("/demo")
public String demo() {
log.info("111111");
String traceId = UUID.randomUUID().toString();
log.info("traceID:{}",traceId);
threadLocal.set(traceId);
log.info("222222,:{}",threadLocal.get());
executorService.execute(()->{
log.info("3333:{}",threadLocal.get());
});
CompletableFuture.runAsync(()->{
log.info("4444:{}",threadLocal.get());
}).thenRunAsync(()->{
log.info("5555:{}",threadLocal.get());
});
log.info("main thread,:{}",threadLocal.get());
executorService.execute(TtlRunnable.get(()-> log.info("child thread 1:{}",threadLocal.get())));
CompletableFuture.runAsync(TtlRunnable.get(()-> log.info("child thread 2:{}",threadLocal.get())))
.thenRunAsync(TtlRunnable.get(()-> log.info("child thread 3:{}",threadLocal.get())));
return "demo";
}

Expand Down