Meaningless Drivel is fun!
The moose likes Threads and Synchronization and the fly likes Threads does it really useful? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Threads does it really useful?" Watch "Threads does it really useful?" New topic

Threads does it really useful?

Jothi Anuragiit

Joined: Oct 26, 2010
Posts: 2

Multitasking can be done if and only if we have multiprocessor.
Threads, actually executes the tasks in the call stack just by pausing one task for some seconds and executing other tasks and again executes the paused task and so on....
So, this means it didn't executes the tasks simultaneously / parallel but it makes the user to feel so.

Do we need threads actually ? Or do i need to know more about threads ?
Jelle Klap

Joined: Mar 10, 2008
Posts: 1951

Exploiting the raw power of a multiprocessor /multicore system is one of the benefits of using a multithreaded solution, sure.
Probably the most obvious one. There are benefits for single-processor / single-core systems as well.
For instance, ensuring responsiveness of a (Swing) user interface for example, by executing long-lived tasks in a thread separate from the EDT.
Another reason could be simplicity, which might seems at odds with the 'inherent complexity' of using threads.
For instance, it might be possible to reduce a singe complex asynchronous sequence of operations to multiple synchronous operations of reduced complexity, each running in a spearate thread and interacting at specific points.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Henry Wong

Joined: Sep 28, 2004
Posts: 20517

Let's not forget that not all tasks are processor intensive. For example, you can certainly have lots of threads doing i/o -- network, files, database, etc. -- and it is perfectly fine for these threads to share the processor. Basically, one thread can be working while many others are waiting for data. This is certainly better than a thread waiting for data, while all the others are waiting for it to finish.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
Do we need threads actually ? Or do i need to know more about threads ?

Yes, you need to learn more about Threads.

Jothi Anuragiit

Joined: Oct 26, 2010
Posts: 2
Thanks friends.
I agree. Here's the link:
subject: Threads does it really useful?
It's not a secret anymore!