1
0
mirror of https://github.com/balkian/SWCM.git synced 2024-11-22 12:42:29 +00:00
SWCM/ServidorConcurrente/ServWebPatternConc.java
2011-04-24 20:50:42 +02:00

34 lines
779 B
Java

package ServidorConcurrente;
import java.util.*;
import java.io.*;
import java.net.*;
public class ServWebPatternConc {
public static int maxCon = 10;
public static void main (String args[]) {
try {
ServerSocket serv = new ServerSocket(8080);
System.out.println("showserver created at port 8080.");
ThreadGroup workers = new ThreadGroup("WebWorkers");
while (true) {
if(workers.activeCount()<maxCon){
System.out.println("Hay "+workers.activeCount()+" hebras corriendo.");
Socket conn = serv.accept();
Thread hs = new Thread(workers, new HebraServ(conn));
hs.start();
}
else{
try{
Thread.sleep(500);
}
catch(Exception ex){
}
}
}
}
catch (IOException e) { System.err.println(e); }
}
}