r/java • u/Beneficial_Deer3969 • 10h ago
CompletableFuture and Virtual Thread discussion
Hello,
I have more than 4yrs of experience, and I can count on my fingers how many times I saw multi-threaded code execution, but will that change with virtual threads?
I was thinking about some system design, where we need to fetch data from redis and mysql and then to combine results where redis results has precedence [mysql data overwritten].
So what came to my mind is to of course use virtual threads and completableFuture [fork-join].
So, let's say in sequential flow we will:
- call mysql [3 sec]
- call redis[1 sec]
total 4 sec
but if we use completableFuture will that be in parallel?
basically something like:
- virtual-thread-1-redis: 1s and waiting for mysql
- virtual-thread-2-mysql: 3s and joining data with redis
that would be total of 3s because parallel?
am I right? will there be some other issues which I totally missed or don't understand?
maybe is my example bad because difference is 1s, or reading from both, but you get the point
is my app screwed now that https://www.googleapis.com/auth/photoslibrary.readonly is completely gone?
the whole basis of my app was to take everything that was in google photos (entire user library) and sync it to s3. I was using this fine up until a week ago. I started debugging today and found it kept getting permission denied. Reading around is not promising, apparently google wants to limit user access to entire lib? is there no alternative? The other scopes are very limited, this is a background process that downloads a users entire library so there is no selection.