Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So here are some details about the solution I used.</p> <p>Starting from this trivial program (HelloWorld.java) which took about 100ms to execute:</p> <pre><code>class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } } $ javac HelloWorld.java $ time java HelloWorld Hello, world! real 0m0.109s user 0m0.030s sys 0m0.030s </code></pre> <p>I converted it into a trivial server:</p> <pre><code>import java.io.*; import java.net.*; class HelloWorldThread extends Thread { private Socket socket; public HelloWorldThread(Socket s) { super("HelloWorldThread"); socket = s; } public void run() { try { PrintWriter out = new PrintWriter(socket.getOutputStream(), true); out.println("Hello, world!"); out.close(); socket.close(); } catch (IOException e) { e.printStackTrace(); } } } class HelloWorld { public static void main(String[] args) { try { ServerSocket serverSocket = new ServerSocket(30281); while (true) new HelloWorldThread(serverSocket.accept()).start(); } catch (IOException e) { e.printStackTrace(); } } } </code></pre> <p>start it once and use <a href="http://en.wikipedia.org/wiki/Netcat" rel="nofollow noreferrer">netcat</a> to connect to it (thanks <a href="https://stackoverflow.com/users/114226/petermmm">PeterMmm</a> for the idea) which resulted in the execution time of just 3ms:</p> <pre><code>$ javac HelloWorld.java $ java HelloWorld &amp; $ time nc localhost 30281 Hello, world! real 0m0.003s user 0m0.000s sys 0m0.000s </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload