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

Reactor's Schedulers.boundedElastic() unsupported #725

Open
chenzhiguo opened this issue Dec 13, 2024 · 0 comments
Open

Reactor's Schedulers.boundedElastic() unsupported #725

chenzhiguo opened this issue Dec 13, 2024 · 0 comments

Comments

@chenzhiguo
Copy link

import com.alibaba.ttl.TransmittableThreadLocal;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Test {

    private final TransmittableThreadLocal<Integer> context = new TransmittableThreadLocal<>();

    private final ThreadLocal<Integer> context2 = new InheritableThreadLocal<>();

    private final ExecutorService threadPool = Executors.newFixedThreadPool(10);

    public static void main(String[] args) throws InterruptedException {
        Test test = new Test();
        for (int i = 100; i < 110; i++) {
            test.test(i);
            Thread.sleep(1000);
        }
    }

    public void test(int i) {
        context.set(i);
        context2.set(i);
        System.out.println("===============Start===============" + i);
        Mono.fromRunnable(() -> {
                    System.out.println("boundedElastic============ttl============" + context.get());
                    System.out.println("boundedElastic============IT============" + context2.get());
                })
                .subscribeOn(Schedulers.boundedElastic())
                .doOnSubscribe(subscription -> System.out.println("Task submission successful:" + i))
                .doFinally(signal -> System.out.println("Task completion signal:" + signal))
                .subscribe();
        context.remove();
        context2.remove();
    }
}

The above is a test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant