Package TCM_MPI.SenderClasses

Source Code of TCM_MPI.SenderClasses.SendData_JvmTcp

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package TCM_MPI.SenderClasses;

import TCM_MPI.Sockets.Interfaces.ISocketTcm;
import TCM_MPI.Sockets.SocketJvm;
import TCM_MPI.CLS.CONST;
import TCM_MPI.CLS.TcmByteData;
import java.net.Socket;
import java.util.concurrent.ArrayBlockingQueue;

/**
*
* @author beecluster
*/
public class SendData_JvmTcp implements Runnable{

    private ArrayBlockingQueue<TcmByteData> _SEND_QUEUE;
    private ISocketTcm _TCM_SOCKET;
   
    public SendData_JvmTcp(ArrayBlockingQueue<TcmByteData> S_QUEUE,Socket SOCKET){
       
        this._SEND_QUEUE = S_QUEUE;
        this._TCM_SOCKET = new SocketJvm(SOCKET);
       
    }
   
    public SendData_JvmTcp(ArrayBlockingQueue<TcmByteData> S_QUEUE,ISocketTcm SOCKET){
       
        this._SEND_QUEUE = S_QUEUE;
        this._TCM_SOCKET = SOCKET;
       
    }
   
    @SuppressWarnings({"CallToThreadDumpStack", "SleepWhileInLoop"})
    private void SendWork(){
       
        while(this._TCM_SOCKET != null){
            try {
               
                TcmByteData DATA = this._SEND_QUEUE.take();
               
                if( this._TCM_SOCKET.SendBytes(DATA.getBytes()) ){
                }else{
                }
               
                Thread.sleep(CONST.SLEEP_SEND_TIME);
               
            } catch (Exception ex) {
                ex.printStackTrace();
            }finally{
            }
           
        }
       
    }
   
    @Override
    public void run() {
        this.SendWork();
    }
   
}
TOP

Related Classes of TCM_MPI.SenderClasses.SendData_JvmTcp

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.