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

Handling large number of threads(Server Side)  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a chatting application which follows a client server architecture, how can we improve/handle excessive thread creation on the server side.
Can someone pls throw light on how servers like Yahoo handle them (some other technique other than increasing memory on the box or load balancing??).


pb citeee
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to solve a specific problem or do you just want less threads created?

It's fairly simple to implement a Thread pool if that's all you require.
 
pb citeee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by David O'Meara:
Are you trying to solve a specific problem or do you just want less threads created?

It's fairly simple to implement a Thread pool if that's all you require.



Hi David,

Thanks for the response.

I want to avoid thrashing on the server side.Let me elaborate - I have a chat client-server appl. that can talk to other third party chat systems(like MSN), so i spawn a separate thread for each system.

Also pls elaborate on the Thread pool(using work queque ??).

Thanks a lot
pb citeee
 
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See JDK 5's Executor and BlockingQueue for some neat background on thread pools. I found these very intuitive to use. If you don't, just give a holler up in the theading forum.

If you're on JDK 1.4 or later, read up on NIO. I need to set aside a block of time to make my Wiki do this just to learn how it works.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!