File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

Threads does it really useful?

Jothi Anuragiit
Greenhorn

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
Bartender

Joined: Mar 10, 2008
Posts: 1753
    
    7

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
author
Sheriff

Joined: Sep 28, 2004
Posts: 18510
    
  40


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.

Henry


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

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


Yes, you need to learn more about Threads.

Bill
Jothi Anuragiit
Greenhorn

Joined: Oct 26, 2010
Posts: 2
Thanks friends.
 
 
subject: Threads does it really useful?
 
Similar Threads
Doug Lea PooledExecutor won't grow larger than minimumPoolSize
Any Examples of using File::Tasks::Edit (Perl Module)
Thread.start() or thread.stop()
Multitasking and Threads
implementing a timed/scheduled task