I am a new comer to threading so please bear with my potentially dumb question.
From what I have read in books the main use of threading is that tasks can be run in parallel and slow tasks won't hog the cpu.
But I can't think of practical scenarios in business applications when tasks need to run in parallel.
Most of these books give examples like word processor or printing which are really system applications.
When we talk about business application can somebody give examples of where they have used multithreading to do parallel tasking and how was this justified?
Few things I can imagine
1. Do multi tasking when there are multiple large running queries in your code that are not necessarily related and can be run in parallel
2. Do multi tasking when interfacing with external systems
But if you are not going outside the "boundaries of a java program" are there valid reasons to do multitasking?
For instance, you might write a program that needs to check status of many computers on your network. You could do the required tasks for one computer at a time, or you could fire off a bunch of threads with each checking a different computer.
Multithreading has its own niche and sometimes we couldn't move forward without it. Here is some common tasks that need to be done in multi-threads:
- Avoid GUI freezing when running a long operation in the background, such as compressing files, scan files & directories, ... The background tasks should be executed in separate threads other than the Event Dispatching Thread, otherwise, the GUI will freeze.
- Upload/Download many files at once, this need be done by multi-threads for maximum speed.
.. and much more.
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads: