Wrox Programmer Forums
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 14th, 2006, 11:58 PM
Registered User
 
Join Date: Oct 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Java

Hello there,
i m developing server in java. i am using socket programming with thred.
my problem is when i run my server it starts producing thread for each client and once it reached maximum number of thread and it degrades performance of my server making it slower.
so i want to limit my server to produce maximum thread of 100, and then it stop producing new threads. until one of the active thread is stop.
so can any one help me to set maximum thread in my server.
how to set maximum thread for the thread
do java provide any technique for that??

please help me this matter.
 
Old October 16th, 2006, 03:32 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You must be creating your threads programmatically in the main thread. In your main thread, don't create new threads once your maximum is hit. Instead, pool them up and wait for an existing thread to become available.

I don't think you need anywhere close to 100 threads, though. Servlet servers like Tomcat by default only create 20 threads for handling requests. So are you sure you're even using existing threads at all? What you want to build is a "thread pool", which the main thread keeps track of. As requests come in, the main thread should pass them off to existing threads that aren't processing current requests.

Jon Emerson
http://www.jonemerson.net/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Root Cause:java.lang.NoSuchMethodError: java.util. anees81 JSP Basics 3 March 1st, 2011 08:55 AM
java.lang.OutOfMemoryError: Java heap space meetkotresh J2EE 1 February 2nd, 2008 01:52 AM
Java Media Framework(I am new to java) amirdiwan4eva Pro Java 4 July 12th, 2006 04:50 AM
Java Code - Wrox - Beginning JAVA - Ivor Horton ponguru Java Databases 3 May 18th, 2006 12:30 PM
Java vs Java Script functions joemorrison74 J2EE 0 July 6th, 2005 04:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.