I know that threads are key members of a software/web application.
But I didn’t use them during my college project which was about online shopping using Java EE technology.
Can someone tell me how they can be useful if I had applied them in my project?
I am familiar with cuncurrency etc but just want a big picture to understand their imoprtance.
For example why should I bother to put some code in threads (apart from the fact of multiple requests and I should bother ). Just a bit confused.
If you’ve done a Java EE project, then threads are something you would not likely have touched. When using Java EE, you’re coding parts that will be plugged in to some container. For example, you code the EJBs and the application server takes care of caching these and calling them. You code persistence entities and the application server will provide you with a persistence context and takes care of transactions…
An application server will have a number of threads pooled to take care of client requests. They’re all managed for you, so you don’t really get to see it. Because you’re coding against a framework.
Switch to Java SE and things are different. If you’re building an application mostly from the ground up, maybe using some libraries but not really a framework, chances are that in a non-trivial application you’ll require multi-threading. Although knowing how or when to use concurrency in the best possible way is something you learn through study and experience (the book “Java concurrency in practice” is sort of the go-to work here), you could basically say that any time something needs to be done in the background while other work is also performed, or your program can continue without having to wait on some call to return, multi-threading can come into play.