@Builder
public class X {
@Nonnull String a;
@Nonnull String b;
}
main () {
X.XBuilder builder = X.builder();
//thread 1
CompletableFuture.runAsync(()-> {
builder.a("some");
});
//thread 2
CompletableFuture.runAsync(()-> {
builder.b("thing");
});
}
Here the same object is being accessed and modified at the same time. So will this code be thread safe?
Usecase is like wants to call multiple api's, each api results is to populate the fields of class X.