This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

multithreaded programming  RSS feed

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as per my understanding, multithreaded programming makes sense only for multi processor environment? but I think there is more.
can someone throw some more light on this?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Multithreaded programming has uses even when you are running the application on a single threaded environment. Some of the examples I am aware of are :

a. GUI programming. Say you click on a button on GUI and it triggers a background process that would take some time to complete. With multithreading the background task can be done in a separate thread and GUI can be responsive to user inputs. Without multithreading in such cases the GUI would appear frozen to the user

b. Webserver: Webservers typically serve a lot of requests, and it can span a new thread to service a request and the main thread can continue
to wait for any new incoming requests.
 
Sheriff
Posts: 21453
96
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Multi threaded programming is useful in any situation where you need a background process to run. User interfaces need multiple threads anytime a long task is running, or the entire user interface freezes. And how about scheduled jobs, these use different threads as well.

If you split one large task into several smaller subtasks and run these in parallel you can actually decrease performance when you are not in a multi processor environment. For instance calculating the sum of a large int array (pseudo code):
If any processor gets more than one job then the overhead of context switching when another thread becomes active will cause a performance decrease.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!