Fortunately, multi-core processors and multi-processor servers now exist that can execute multiple tasks in parallel and Java supports dividing program execution into threads. In code this can be implemented by creating classes that implement the Runnable interface with "run" method.
However, creating a separate thread for each task also doesn't make sense, as the number of cores/processors is limited. Therefore, it's common to create a pool of threads and distribute the threads among them with "thread.submit".
But even without multi-core processors, dividing a program into threads could be useful. For example, some tasks depend on external systems and spend a significant amount of time waiting for external API responses. By separating such tasks into separate threads, you can provide the process with a different payload while it's waiting.
But when creating multiple threads you need to be careful. Every program has tasks/methods that cannot be executed by two threads simultaneously (for example, changing the same data in a database). Such methods must be marked by "synchronized" - then the first thread will block the method until it completes, preventing other threads from accessing it.
Sometimes, it's also necessary to configure the priority of threads accessing an object. For example, the CEO's thread should have priority over employee's. For this purpose, Java provides tools for manually regulating thread access to an object (ReentrantLock, Condition).
Here are some good books on Multithreading in Java:
Multithreaded Programming with Java Technology
2000 by Bil Lewis, Daniel J. Berg

Download PDF
Java Multi-Threading Programming: MULTITHREADING & CONCURRENT, FILE IO & NETWORKING
Neos Thanh - 108 pages by Neos Thanh

Download PDF
Multithreading and Concurrency in Java: A Practical Guide to Threads, Synchronization and Concurrent Programming
Prashant by Prashant Mondkar

Download PDF
See also: Top 10 eBook Organizers
How to download PDF:
1. Install Gooreader
2. Enter Book ID to the search box and press Enter
3. Click "Download Book" icon and select PDF*
* - note that for yellow books only preview pages are downloaded


