|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--jclass.SleepingThread | +--jvm.entity.TCPIPReadThread
(please read also bellow !) A thread that reads messages from
the network and tries to put them
into a queue. It blocks if the queue becomes full and waits for some queue
entries to free up.
(The above was the original stuff)
Now, there appears the case in which we
might just NOT want to fill up the queue but to do something fast and
useful with any new incomming message. This is why we have to provide a
mean by which every time the thread reads a message it also calls
another external object's (some sort of observer) method with the just
received message as parameter. This other object is a MessageHandler.
That means that a correct description of this would be something like:
A thread that reads messages from the network and for each new
message it calls the MessageHandler.newmsg() method.
Written: Radu Sion
Version: 1.19
Source: TCPIPReadThread.java
Visit
Smart Software
Message
,
MessageHandler
,
SimpleQueue
,
FullException
,
EmptyException
,
TCPIPWriteThread
,
SleepingThread
Fields inherited from class jclass.SleepingThread |
DEFAULT_SLEEP |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY,
MIN_PRIORITY,
NORM_PRIORITY |
Constructor Summary | |
TCPIPReadThread(EntityID id,
SmartObjectInputStream is,
MessageHandler msgh,
int max_messages,
long sleep)
Constructs a new TCPIPReadThread. |
Method Summary | |
protected void |
finalize()
|
boolean |
getActive()
Gets the thread's current status. |
void |
run()
|
void |
setActive(boolean how)
Sets the thread's status. |
void |
setEntityID(EntityID id)
Sets the internal used entity id. |
boolean |
setMessageHandler(MessageHandler msgh)
This sets the incomming message handler. |
Methods inherited from class jclass.SleepingThread |
getSleep,
mysleep,
pause,
pause,
setSleep |
Methods inherited from class java.lang.Thread |
activeCount,
checkAccess,
countStackFrames,
currentThread,
destroy,
dumpStack,
enumerate,
getContextClassLoader,
getName,
getPriority,
getThreadGroup,
interrupt,
interrupted,
isAlive,
isDaemon,
isInterrupted,
join,
join,
join,
resume,
setContextClassLoader,
setDaemon,
setName,
setPriority,
sleep,
sleep,
start,
stop,
stop,
suspend,
toString,
yield |
Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public TCPIPReadThread(EntityID id, SmartObjectInputStream is, MessageHandler msgh, int max_messages, long sleep)
id
- EntityID of the current entity. This is needed in the call to MessageHandler.newmsg()is
- ObjectInputstream from which to readmsgh
- MessageHandler to usemax_messages
- Number of messages to read. (if -1 then read in loop)sleep
- Internal sleep delayMethod Detail |
public void setActive(boolean how)
public boolean getActive()
setActive(boolean)
public boolean setMessageHandler(MessageHandler msgh)
mh
- New MessageHandler to setpublic void setEntityID(EntityID id)
public void run()
protected void finalize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |