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

k8s环境下CPU调整>2数量后线程上下文传递失效 #579

Closed
llm163520 opened this issue Nov 24, 2023 · 1 comment
Closed

k8s环境下CPU调整>2数量后线程上下文传递失效 #579

llm163520 opened this issue Nov 24, 2023 · 1 comment
Assignees
Labels
❓question Further information is requested

Comments

@llm163520
Copy link

llm163520 commented Nov 24, 2023

代码示例:

e866b2aacd4586cca6bc257e48c3aaf
final  ThreadLocal<Object> key = new TransmittableThreadLocal<>();
key.set("key");
CompletableFuture.runAsync(ThrowingRunnable.throwing(() ->
    System.out.println("key: "+key.get())
)).get();

K8S配置:

4ad5cd0862abf5dee3ec50e166858de
@llm163520 llm163520 changed the title k8s环境下CPU调整为线程上下文传递失效 k8s环境下CPU调整>2数量后线程上下文传递失效 Nov 24, 2023
@oldratlee
Copy link
Member

oldratlee commented Nov 26, 2023

需要有TTL的修饰操作,使用方法如下: @llm163520
(更多具体内容如其它的使用方式,请查看文档 👥 User Guide

final ThreadLocal<Object> context = new TransmittableThreadLocal<>();
context.set("key");

final Runnable bizRunnable = ...;
// 对传入的Runnable 做TTL修饰(可以有其它的使用方式,参见「👥 User Guide」)
CompletableFuture.runAsync(TtlRunnable.get(bizRunnable)).get();

PS: 与K8S这样的运行环境无直接关系。

相关 issue

@oldratlee oldratlee self-assigned this Nov 26, 2023
@oldratlee oldratlee added the ❓question Further information is requested label Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants