• Post Reply Bookmark Topic Watch Topic
  • New Topic

Will muti-threading make you program run faster?

 
Edy Yu
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My answer to that question is no. It will even slow down your program by constructing and starting multiple threads.
Am I right?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Edy Yu:
My answer to that question is no. It will even slow down your program by constructing and starting multiple threads.

The right answer is "depends". Multithreading may increase real performance by allowing you to do useful work while you would otherwise do nothing, for instance, when waiting for a blocked I/O call. There is no question that multithreading increases the performance of a web server.
It may also increase perceived performance by allowing your application to remain responsive, update the display etc. while some background activity is going on. There is no question that people will experience an improvement of the performance of your word processor if you do the spellchecking in the background, even if that means the spellcheck takes twice as long.
- Peter
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great answer, Peter!!!
Just add one more point, the speed improvement will be more obvious if your computer has multi-processors.
Roseanne
 
cameron weirs
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter already told the essence of multithreading for improving performance ,
as per my experience i believe u gotta know what task to put on how much priority thread and synchrize them properly so as to add positively towards performance of your application..
A group of poorly prioritized threads might slow your application to the level of unacceptable limits ..
 
karl koch
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
(i think)
ulti threaded code does not profit from multiple cpu's by default. it depends (wee, again) on the code. sometimes cpu-cpu communication will introduce more overhead.
right ?
karl
 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there Edy! i know i saw something really useful about this topic on the java jumpstart cd... i'll get back to you after i find my copy.
 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here you go...
Tech Tips on Threads
------------------
aka pinboxx
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!