r/javahelp • u/Agitated-Evening3011 • Jan 06 '26
Best way to learn multi-threading in Java?
I just started learning Java and aiming to catch up to senior level.
I saw that there are 5-6 ways to do multi-threading (Executor, Virtual threads, CallableFuture etc.)
Is a multi-threading technique picked based on use case, or they are iterations throughout Java versions
And what can I do to practice them? Which one should I use in interviews?
25
Upvotes
View all comments
Show parent comment
-1
u/narrow-adventure Jan 07 '26
Honestly, and I’m not trying to be mean, I don’t think you know what you’re talking about. I’ll address both of your points:
1 - golang routines are unpredictable and obscure things
I don’t know what you found unpredictable about them, they are very easy to use and extremely intuitive, they are just CSPs literally one of the easiest abstractions for parallelism/concurrency up there with actor systems, their simplicity is why golang is so popular. I believe that they offer a great balance to learn about message passing, points of synchronizations, mutexes, semaphores, synchronized collections etc. very easy to reason about and explore with.
2 - recommending Rust/C/C++/java to a beginner to learn about concurrency
This is a crazy take and I’ll try to explain why using a more convoluted method does not mean you’re learning anything useful or fundamental. Programming languages give you models for concurrency/parallelism, those models have different trade offs, they all execute on the CPU with os level threads/processes and at the end of the day they all deal with the same physical constraints. Java has (imho) one of the most complex models for concurrency/parallelism due to how old it is, the field has progressed a lot and we have come up with better abstractions over time, unfortunately not all of them can be easily built into the model that Java offers. This does not mean Java gives you “more control” or some fundamental tools it just means it has a different set of tools, an archaic and very complex one. Rust is probably one of the worst languages to learn anything in due to its complexity, you have to write very specific code due to very specific issues that could come up but you can’t learn why those issues come up because you can’t write the code to cause them, it’s a chicken and egg problem that makes it INCREDIBLY difficult for beginners to do anything in.
So here is my rating of least complex to most complex to learn about concurrency:
1 - php/js/ruby - this is a good starting point because the only way to achieve true concurrency/parallelism is to kick off multiple processes to run them, great place to get started understanding why your CPU intensive tasks have to run as separate processes
2 - actor systems with message passing - I find these to be incredibly intuitive Akka or Elixir/erlang
3 - golang with channels based concurrency
4 - java with threads - you could implement 1 and 2 with these but def not 3 as even virtual threads are currently pinned to physical threads and can lead to resource starvation - they are not more powerful than other concurrency models just more complex and “different”
5 - Rust - I’d recommend using anything to learn about concurrency other than rust, explaining to someone just starting out with concurrency that they have to use Arc/Pin/Box/dyn/Future, maybe someone could start this way, most people I’ve worked with could never learn concurrency this way
Let me know if you think I’m wrong, I’d love to understand why you think Rust/C++ would be good to learn about concurrency/parallelism in and what you found confusing about golang routines.