Class NIC

java.lang.Object
  extended byjava.lang.Thread
      extended byNIC
All Implemented Interfaces:
Actions, Runnable

public class NIC
extends Thread
implements Actions

The class creates token then Passes token to neighbour NIC and holds token while the resource in use bu user

Version:
Version 1
Author:
Adeel Hashmi

Field Summary
protected static boolean loop
          Thread looping flag
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface Actions
EXIT, NOPASSING, PASS, PASSTOKEN, READ
 
Constructor Summary
NIC()
          Constructor set the intital status to NOPASSING
 
Method Summary
protected  void checkStatus()
          Check status and pass token
protected  void createToken()
          create the token intially and set status to pass The method should call before starting thread
protected  Token exchangeToken(Token r)
          exchanges token value from neighbour NIC
protected  void Exit()
          This methods terminates the run method by setting flag
protected  Token getToken()
          Return token reference
 void run()
           
protected  void setNeighbour(NIC n)
          set neighbout NIC to communicate and pass token The method should call before starting thread
protected  void setStatus()
          change status to pass token
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

loop

protected static boolean loop
Thread looping flag

Constructor Detail

NIC

public NIC()
Constructor set the intital status to NOPASSING

Method Detail

checkStatus

protected void checkStatus()
                    throws Exception
Check status and pass token

Throws:
Exception

createToken

protected void createToken()
create the token intially and set status to pass The method should call before starting thread


exchangeToken

protected Token exchangeToken(Token r)
exchanges token value from neighbour NIC

Parameters:
r - token to exchange

Exit

protected void Exit()
This methods terminates the run method by setting flag


getToken

protected Token getToken()
Return token reference


run

public void run()
Specified by:
run in interface Runnable

setNeighbour

protected void setNeighbour(NIC n)
set neighbout NIC to communicate and pass token The method should call before starting thread

Parameters:
n - Neighbour NIC

setStatus

protected void setStatus()
change status to pass token