Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads does it really useful?

 
Jothi Anuragiit
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 1952
7
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Henry Wong
author
Marshal
Pie
Posts: 21498
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks friends.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic