GitHub user tisonkun added a comment to the discussion: Use single 
AsyncExecutor for all operations

<img width="1727" alt="image" 
src="https://github.com/user-attachments/assets/47d8af46-c042-4e7b-a765-fee4cc5a7c86";>

Tested and confirmed that the threads are reused.

Thread-1024 ~ Thread-1035 are OpenDAL threads. The available cores on my laptop 
are 12.

```java
    @Test
    void testMassiveOperator() throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);
        final CountDownLatch inner = new CountDownLatch(1024);
        final Map<String, String> conf = new HashMap<>();
        conf.put("root", "/opendal/");

//        final int n = 1;
//        try {
//            @Cleanup final AsyncOperator op = AsyncOperator.of("memory", 
conf);
//            op.write("key-" + n, ("v" + 
n).getBytes(StandardCharsets.UTF_8)).join();
//            latch.await();
//        } catch (Exception e) {
//            throw Lombok.sneakyThrow(e);
//        }

        for (int i = 0; i < 1024; i++) {
            final int n = i;
            final Thread thread = new Thread(() -> {
                try {
                    @Cleanup final AsyncOperator op = 
AsyncOperator.of("memory", conf);
                    op.write("key-" + n, ("v" + 
n).getBytes(StandardCharsets.UTF_8)).join();
                    inner.countDown();;
                    latch.await();
                } catch (Exception e) {
                    throw Lombok.sneakyThrow(e);
                }
            });
            thread.setName("AsyncOperator-" + i);
            thread.start();
        }

        inner.await();
        latch.countDown();
    }
}
```

GitHub link: 
https://github.com/apache/opendal/discussions/5096#discussioncomment-10575502

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to