Created
May 27, 2014 07:00
-
-
Save Fuud/35e6f3b525d2df8ae7bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ringcentral.subscriptions.common; | |
import java.io.IOException; | |
import java.net.ServerSocket; | |
import java.net.Socket; | |
import java.util.concurrent.Executor; | |
import java.util.concurrent.Executors; | |
public class Test { | |
private static final Executor executor = Executors.newCachedThreadPool(); | |
public static void main(String[] args) throws Exception{ | |
ServerSocket socket = new ServerSocket(4545); | |
while (true){ | |
try { | |
final Socket accept = socket.accept(); | |
executor.execute(new Runnable() { | |
@Override | |
public void run() { | |
process(accept); | |
} | |
}); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
private static void process(Socket accept) { | |
// some work | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment