Untitled

mail@pastecode.io avatar
unknown
java
2 months ago
700 B
8
Indexable
Never
    @Data
    static class TestDto {
        int a, b, c;

        void setA(int a) {
            this.a = a;
            log.info("Setting A");
        }

        void setB(int b) {
            this.b = b;
            log.info("Setting B");
        }

        void setC(int c) {
            this.c = c;
            log.info("Setting C");
        }
    }

    @Test
    void execute() {
        TestDto test = new TestDto();
        CompletableFuture.allOf(
                CompletableFuture.runAsync(() -> test.setA(1)),
                CompletableFuture.runAsync(() -> test.setB(2)),
                CompletableFuture.runAsync(() -> test.setC(3))
        ).join();
    }
Leave a Comment