# HG changeset patch # User e085711 # Date 1307330772 -32400 # Node ID dd1321b67f95845c78b3008c6f92cc091e8b6f85 # Parent f399eec66846ed787c2a93aef84675cd133e44dd sendReadData : newSingleThreadExecutor() diff -r f399eec66846 -r dd1321b67f95 src/myVncProxy/MyRfbProto.java --- a/src/myVncProxy/MyRfbProto.java Sun Jun 05 22:30:46 2011 +0900 +++ b/src/myVncProxy/MyRfbProto.java Mon Jun 06 12:26:12 2011 +0900 @@ -11,13 +11,13 @@ import java.net.BindException; import java.net.ServerSocket; import java.net.Socket; -import java.nio.ByteBuffer; import java.util.LinkedList; import javax.imageio.ImageIO; -import org.omg.CORBA.portable.OutputStream; - +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.io.OutputStream; class MyRfbProto extends RfbProto { @@ -39,6 +39,9 @@ private LinkedList sendThreads; boolean createBimgFlag; + ExecutorService executor; + + byte[] pngBytes; MyRfbProto(String h, int p, VncViewer v ) throws IOException { @@ -47,6 +50,8 @@ cliListTmp = new LinkedList (); createBimgFlag = false; sendThreads = new LinkedList (); +// executor = Executors.newCachedThreadPool(); + executor = Executors.newSingleThreadExecutor(); } MyRfbProto(String h, int p) throws IOException { @@ -55,6 +60,8 @@ cliListTmp = new LinkedList (); createBimgFlag = false; sendThreads = new LinkedList (); +// executor = Executors.newCachedThreadPool(); + executor = Executors.newSingleThreadExecutor(); } void initServSock(int port) throws IOException{ @@ -211,41 +218,23 @@ readFully(buffer); sendData(buffer); } - void readSendData()throws IOException { + void readSendData()throws IOException{ byte buffer[] = new byte[dataLen]; readFully(buffer); reset(); - LinkedList threads; - threads = new LinkedList(); - for(Socket cli : cliList){ -// try{ -// OutputStream out = (OutputStream) cli.getOutputStream(); -// Thread th = new Thread(new SendThread(out, buffer)); - Thread th = new Thread(new SendThread(cli, buffer)); - threads.add(th); -/* - }catch(IOException e){ - // if socket closed + try{ + OutputStream out = cli.getOutputStream(); + executor.execute(new SendThread(out, buffer)); + }catch(IOException e){ + // if client socket closed cliListTmp.remove(cli); }catch(Exception e){ } -*/ - } - - for(Thread thread : threads){ - thread.start(); + } - try{ - for(Thread thread : threads){ - thread.join(); - } - }catch(InterruptedException e){ - - } - } void regiFramebufferUpdate()throws IOException{ mark(20);