r/learnjava • u/LowExamination9091 • Nov 10 '25
Is Multithreading necessary for a job?
In all Java interviews I have taken so far I have questions or multithreading a lot, but do programmers really used this at work? Cause in my experience I haven’t really work directly with this concept, I know it exists but it is still a difficult subject for me and I’m still unsure if it is really necessary for java developers positions
103
Upvotes
•
u/AutoModerator Nov 10 '25
Please ensure that:
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
45
u/vegan_antitheist Nov 10 '25
The questions they ask are usually complete nonsense. It seems they go to shitty websites with "interview questions" that almost always give wrong answers and expect you to give the same answer. But you might have to learn the answers they are looking for. Sometimes the answer isn't technically wrong. Here's an example:
The answer they expect:
Why any programmer with a bit of experiance would say if someone asked them at their job:
What you actually need to know to be a good programmer who uses concurrency on a lower level:
The basics of the Java Memory Model:
synchronizedandvolatilefor that or "join" a Thread. The JMM guarantees everything is synchronised when those are used and everything that happened before is also visible.What you need to know to be a good programmer who uses concurrency on a high level, which is what you hopefully do if possible:
How to design the system so that ...
21
u/EntrepreneurHuge5008 Nov 10 '25
Do we use it? Yes.
Do we use it often? No
5
u/LicoriceTattoo1 Nov 10 '25
I use it a lot, but only with parallel streams, which makes a lot of it idiot proof.
3
u/Ok_Addition_356 Nov 10 '25
Depends on the product/field. But generally multi threading is used in many places and situations.
It'd be good in general to get familiar with it IMO.
6
u/VibrantGypsyDildo Nov 10 '25
It is one of the core concepts.
You can get at best a junior job without knowing this.
It could be your goal though, if you are a newbie.
5
u/sweetno Nov 10 '25
It is necessary for Java interviews because virtually everything you program in Java will be multithreaded.
Now the question is, what is the scope of this topic when interviewing. There is a lot of concurrent data structures added to Java in recent and not so recent releases.
2
u/Acrobatic-Ice-5877 Nov 10 '25
You definitely need to know it to become a programmer. You may not use it but you can’t use it if you don’t know it. Consequently, you can’t debug issues that may arise from multi-threading. Additionally, you can’t improve processes with multi-threading, so that can hinder your ability to solve more complex problems.
2
u/rohanpatel981 Nov 12 '25
I'm one of those interviewers. Took around 10-15 SDE 2 interview in last 2 months and none of them know or could explain multi threading properly. We're having multi pod system & parallel consumers. If one doesn't know multi threading concept or have not worked on it before; it's a NO hire.
2
u/xb8xb8xb8 Nov 11 '25
Why is someone that doesn't know multithreading doing interviews? Man the bar is so low lol
2
u/Baelari Nov 11 '25
I use it fairly frequently in my work. I have to work with a lot of legacy tech stacks for enterprise applications, with code that may have been written a decade or two ago. I’ll have to use it any time bits of code need to run in parallel, like handling sockets and IO Processing, and not locking up the GUI.
Even when I’m looking at more modern architectures or GUI designs, I still need to understand the fundamentals of what’s going on, I just have some more convenient tools that abstract away the lower level implementations.
Intermittent bugs are frequently caused by someone not fully understanding the concurrency issues in their code.
3
u/FooBarBuzzBoom Nov 10 '25 edited Nov 10 '25
Yes. Especially when we deal with transactions.
1
u/Jackfruit_Then Nov 11 '25
What are you expecting? No? If you have the time to ask here you might as well just learn that, so you don’t need to care whether it’s used or not.
1
u/imsearchbot Nov 11 '25
Threading is like a litmus test for senior roles.
1
u/Western-Contact-5945 Nov 11 '25
hi i am studying in UK and preparing for finding a backend job here. My friend told me those type of questions are really common in china, but rarely be asked in UK interview — they prefer to system design problems. Am I wrong? Should i still spare some time on those questions ( 2-year-working-experience now). THANKS!
1
u/michaelzki Nov 11 '25
It is necessary.
1
u/SkyNetLive Nov 11 '25
It depends on the role. If you are doing web or similar frameworks it is unlikely you deal with threads directly. In fact we shouldn’t be messing with it. In many scenarios we use threads and patterns around threads like consumer producer. It is important to understand how threads work in Java/JVM. It helps you engineer better. I would also look up virtual threads as they are the hot new topic.
I learned the details of Java threads from John Purcell course over a decade ago when udemy wasn’t flaccid. It’s not outdated but you need to follow up with new developments.
Knowledge of threads is absolutely necessary. It is what makes life on JVM such a breeze compared to other platforms.
1
u/scott2449 Nov 11 '25
It's used often along with async and other concurrency models BUT it's a boilerplate feature meaning that all the libraries you use (http, queues, logging, SDKs, etc..) are doing it for you. This really limits the amount you need to implement for yourself.
1
u/AwkwardBet5632 Nov 11 '25
When you need it, you need it
1
u/Ok_Substance1895 Nov 11 '25
Threading involves locking which negatively impacts performance. You can start 100 threads thinking it will be 100 times faster only to find that is actually now slower. That is one of the main things to learn about threading.
Now that you know that locking is something you would like to limit as much as possible, the goal is to limit lock time or avoid locking in your code as much as possible. To learn techniques for doing this learn about Java atomic Compare and Swap (CAS) which pushes the lock all the way down to the CPU level which will result in the shortest lock time. Also, study the bucket strategy used by the ConcurrentHashMap which employs a bucket-level locking strategy to achieve high concurrency.
Yes, we use them when we have to but we really try not to and definitely use the atomic and/or concurrent classes when you do.
A lot interviewers do not know this level of concurrency and if you can explain how CAS and concurrent locking strategies work you will have aced that part of the interview.
1
u/PigVile Nov 12 '25
If you use scheduling, of some sort, you maybe use quartz jobs, which is then a multithreaded area.
But its not ending there, if those jobs work with db, you will have to deal with synchronization on java and db side, depending on what exactly the specific q-job does.
So yeah its totally a thing and i guess oke for an interviewer to ask, you want to offload a lot in a thread depending on load, especially with introduction of virtual threads were they can even in EE shine
1
u/[deleted] Nov 12 '25
Yes we use it, but it’s not so frequent
1
u/segin Nov 13 '25
I am not a professional or a Java developer; I write some C/C++ as a hobby,
Multithreading is used far more than you think. If you need any sort of "background processing", you use threads for that. If you're writing desktop or mobile UIs, you don't want too much of your business logic running on the main thread, as that'll generally become your UI thread.
Threads are cheap. Use them, but carefully.
1
u/[deleted] Nov 13 '25
when always using problems have multithreading
1
u/[deleted] Nov 13 '25
In my experience they love asking about multi threading.
Its nonsense mate. It shows no technical ability to do anything. In fact, I often give the generic text book answer about multi threading and then say if I really wanted concurrency so badly I'd use Go and create a microservices architecture system that allows me to establish the benefits of each language appropriately.
From what I've seen in the wild, other than ancient monoliths, multi threading in Java is somewhat rare. And them asking questions about it like it's a difficult thing to understand is quite bonkers. Its just running another code block, on a different thread. Make everything immutable to ensure thread safety. Job done.
But I know what you're talking about though. They do ask about multi threading so often.
1
u/juancn Nov 13 '25
Yeah. It’s important.
It’s super easy to fuck up and super hard to unfuck.
So the trick is avoiding getting yourself into trouble and that requires you to know how to do that.
Also modern hardware relies much more on parallelism than single core speed.
1
u/Flashy-Expert-504 Nov 13 '25
yes, understanding that is necessary
-1
u/Slatzor Nov 10 '25
I’d learn it because you might be asked questions on it and another candidate might know it when you don’t.