Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ServerSocket serverSocket = ...;
- while (!serverSocket.isClosed()) {
- Socket client = serverSocket.accept();
- new Thread(() -> {
- InputStream input = client.inputStream();
- final OutputStream output = client.outputStream();
- while (!client.isClosed()) {
- query = readQuery(input);
- threadPool.submit(() -> {
- result = processQuery(query);
- synchronized(output) {
- write(output, result);
- }
- });
- }
- }).start();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement