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.
|
|