Programming tutorials online .NET, Java, C++, Visual Basic, and More
 

Home
.NET Tutorials
General Programming Tutorials
Community/Forums
Site Extras

 

Java/J2EE Forum
 

Open forum for discussing anything Java related. J2EE, JSPs, servlets, EJBs, JDBC, its all fair game and can be found in the Java/J2EE forum!


POST REPLY
Posted By: TakeOut{u}   2/21/2007 12:12:00 AM
Reply To: ruchira who posted...
 
say its a server that launches threads upon connection.

public static int connCount;

which is incremented or decremented in the constructor / deconstructor of the thread class that launches .

public Class Run{
public Class serv{
public static int connCount;
Serv(){
connCount++;
}
-Serv(){
connCount--;
}


}
public static void main(String Args[]){
//bla bla bla
// to launch we instantiate serverSocket and wait for connection
// then on connection, logic
if (serv.connCount > 50){
// Deny because of Max users
}
else{
// Carry on
}

}

}

i hope that helps, my java is a tad rusty, and i'm not sure about the sign in front of the deconstructor. preferably you'd use static class method to access connCount.

Make sure you understand what static means.



 
Sign In
Email
Password
  Forgot my password

Search

Featured Book

Introducing Microsoft .Net, Third Edition ($19.79)
Introducing Microsoft .Net, Third Edition


Featured Software

Microsoft Visual Studio Standard 2005 ($249.99)
Microsoft Visual Studio Standard 2005