• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

what makes threads the Threads?

 
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my question is we can make any application without a thread , so then why do we need a thread
i understand thread is a light weight process but still
what makes threads so usefull ?
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Every Java application uses threads. A standalone application uses at least one main thread which is implicitly created when you start an application. Applications running inside a Servlet container or application server even use many more threads.

Threads are useful if you want to have your application do more than one thing in parallel to improve performance. Multi-threaded programming is particularly useful with modern multi-core CPUs to get the most out of your hardware. If an application isn't designed to run with multiple threads you won't gain any improvement by using CPUs with more than a single core.

Marco
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marco Ehrentreich wrote:Every Java application uses threads. A standalone application uses at least one main thread which is implicitly created when you start an application. Applications running inside a Servlet container or application server even use many more threads.

Threads are useful if you want to have your application do more than one thing in parallel to improve performance. Multi-threaded programming is particularly useful with modern multi-core CPUs to get the most out of your hardware. If an application isn't designed to run with multiple threads you won't gain any improvement by using CPUs with more than a single core.

Marco



thanks but i have one more thing to ask is that i m making my final year project which is a bussiness management system which handles all the data about employess , and there attendence and salary and also this system contains tender management module ..till now i have just one thread and that too is main thread should i go for multi threads for this project
yes or no , if yes than should i make each and every listener class a thread .
if no ..then why ?
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately it's not that easy to judge if it would make sense for your project to make extensive use of multi-threading. If you are unfamiliar with concurrency principles and you don't have any experience with threads I would recommend to not use multi-threading if there's no real need for it. Concurrent programming with multiple threads can be very tricky and chances are good that you will mess up your project.

Marco
 
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic