MCPcopy Create free account
hub / github.com/deepu105/concurrency-benchmarks / JavaHTTPServer

Class JavaHTTPServer

javaws/src/JavaHTTPServer.java:5–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import java.net.Socket;
4
5public class JavaHTTPServer {
6 public static void main(String[] args) {
7 var count = 0; // count used to introduce delays
8 // bind listener
9 try (var serverSocket = new ServerSocket(8080, 100)) {
10 System.out.println("Server is listening on port 8080");
11 while (true) {
12 count++;
13 // listen to all incoming requests and spawn each connection in a new thread
14 new ServerThread(serverSocket.accept(), count).start();
15 }
16 } catch (IOException ex) {
17 System.out.println("Server exception: " + ex.getMessage());
18 }
19 }
20}
21

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected