001/* jpvmRecvThread.java 002 * 003 * A jpvmRecvThread is a thread of control in a JPVM program 004 * responsible for receiving messages on a single receive 005 * connection and enqueing them on a massage queue. 006 * 007 * Adam J Ferrari 008 * Tue 06-04-1996 009 * 010 * Copyright (C) 1996 Adam J Ferrari 011 * 012 * This library is free software; you can redistribute it and/or 013 * modify it under the terms of the GNU Library General Public 014 * License as published by the Free Software Foundation; either 015 * version 2 of the License, or (at your option) any later version. 016 * 017 * This library is distributed in the hope that it will be useful, 018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 020 * Library General Public License for more details. 021 * 022 * You should have received a copy of the GNU Library General Public 023 * License along with this library; if not, write to the 024 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 025 * MA 02139, USA. 026 */ 027 028package jpvm; 029import jpvm.jpvmException; 030import jpvm.jpvmMessage; 031import jpvm.jpvmRecvConnection; 032import jpvm.jpvmMessageQueue; 033import jpvm.jpvmDebug; 034 035public 036class jpvmRecvThread extends Thread { 037 private jpvmRecvConnection conn; 038 private jpvmMessageQueue queue; 039 int my_num; 040 static int num = 0; 041 042 043 public jpvmRecvThread(jpvmRecvConnection c, jpvmMessageQueue q) { 044 conn = c; 045 queue = q; 046 num++; 047 my_num = num; 048 } 049 050 public void run() { 051 boolean alive = true; 052 while(alive) { 053 try { 054 jpvmDebug.note("jpvmRecvThread ("+my_num+") - blocking "+ 055 "for a message."); 056 jpvmMessage nw = new jpvmMessage(conn); 057 jpvmDebug.note("jpvmRecvThread ("+my_num+") - got a "+ 058 "new message."); 059 queue.enqueue(nw); 060 Thread.yield(); 061 } 062 catch (jpvmException jpe) { 063 jpvmDebug.note("jpvmRecvThread, " + 064 "connection closed"); 065 alive = false; 066 } 067 } 068 } 069};