Package jpvm

Source Code of jpvm.jpvmRecvThread

/* jpvmRecvThread.java
*
* A jpvmRecvThread is a thread of control in a JPVM program
* responsible for receiving messages on a single receive
* connection and enqueing them on a massage queue.
*
* Adam J Ferrari
* Tue 06-04-1996
*
* Copyright (C) 1996  Adam J Ferrari
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
* MA 02139, USA.
*/

package jpvm;
import jpvm.jpvmException;
import jpvm.jpvmMessage;
import jpvm.jpvmRecvConnection;
import jpvm.jpvmMessageQueue;
import jpvm.jpvmDebug;

public
class jpvmRecvThread extends Thread {
  private jpvmRecvConnection  conn;
  private jpvmMessageQueue  queue;
  int my_num;
  static  int num = 0;
 

  public jpvmRecvThread(jpvmRecvConnection c, jpvmMessageQueue q) {
    conn  = c;
    queue = q;
    num++;
    my_num = num;
  }
 
  public void run() {
      boolean alive = true;
      while(alive) {
        try {
    jpvmDebug.note("jpvmRecvThread ("+my_num+") - blocking "+
      "for a message.");
    jpvmMessage nw = new jpvmMessage(conn);
    jpvmDebug.note("jpvmRecvThread ("+my_num+") - got a "+
      "new message.");
    queue.enqueue(nw);
    Thread.yield();
        }
        catch (jpvmException jpe) {
      jpvmDebug.note("jpvmRecvThread, " +
        "connection closed");
        alive = false;
        }
      }
  }
};
TOP

Related Classes of jpvm.jpvmRecvThread

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.