• Post Reply Bookmark Topic Watch Topic
  • New Topic

Example Applications using Threads

 
Avianu Sud
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks,
What applications have critical need to use Threads, and manage Threads?
If you can share some application you were involved in, and why Threads were useful (or not useful) that will be great.

I typically build web based applications (EJB's, Servlets) and never need to use Threads.

I guess Applets/Swing apps will use lots of Threads?

Please share your experience & views,
- Avi
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With Swing apps it is common to run the keyboard and mouse events on the Swing thread and spawn new threads to do long-running tasks. Printing might be the most familiar example for desktop apps.

It can be challenging to write a UI that makes it clear to the user what's happening and correctly responds to completion of the worker threads, but good clean fun. I have a little app that downloads files and runs as many threads as you ask. Since there is quite a bit of network latency, one thread can run while another is waiting for data.
 
balach krishnana
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai i want core java q&a
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I typically build web based applications (EJB's, Servlets) and never need to use Threads.

That surprises me. I find that there are plenty of asynchronous or long-running operations where a user cannot be expected to wait for a servlet to respond, or where a servlet might time out.
They also come in handy to schedule nightly jobs or cleanup tasks, where there is no user interaction. Maybe you've used them in the form of java.util.TimerTask?
 
Avianu Sud
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, use TimerTask for those, and usually those are controlled, such as checking for requests and performing operations.

Good point. Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!