Class ClientThread

  • All Implemented Interfaces:
    java.lang.Runnable

    public class ClientThread
    extends java.lang.Thread
    Thread that manages the interaction with the remote service. It is required to allow commands to be issued to the remote services in parallel. This threads prevent the main thread of execution to be blocked by the remote calls to the remote services. A synchronization mechanism to issue and access commands is provided by ThreadSynchronizer.
    Since:
    Ptolemy II 5.1
    Version:
    $Id$
    Author:
    Daniel Lazaro Cuadrado (kapokasa@kom.aau.dk)
    See Also:
    ThreadSynchronizer
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (kapokasa)
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int EXIT
      Exit command.
      static int FIRE
      Fire command.
      static int INITIALIZE
      Initialize command.
      static int ITERATE
      Iterate command.
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor Description
      ClientThread​(ThreadSynchronizer synchr, net.jini.core.lookup.ServiceItem serv)
      Construct a ClientThread with a given ThreadSynchronizer and a given service.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      net.jini.core.lookup.ServiceItem getService()
      Return the service that this ClientThread controls.
      void run()
      Runs the thread.
      void setIterationCount​(int iterationC)
      Specify the number of times that the iteration command is to be performed.
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ClientThread

        public ClientThread​(ThreadSynchronizer synchr,
                            net.jini.core.lookup.ServiceItem serv)
        Construct a ClientThread with a given ThreadSynchronizer and a given service.
        Parameters:
        synchr - A ThreadSynchronizer.
        serv - The service corresponding to the remote service that the Client Thread represents.
    • Method Detail

      • getService

        public net.jini.core.lookup.ServiceItem getService()
        Return the service that this ClientThread controls.
        Returns:
        A ServiceItem corresponding to the service this Client Thread is managing remotely.
      • run

        public void run()
        Runs the thread. The thread blocks until it gets a command. When a command is fetched, the service performs remotely the method corresponding to the given command. Once the task is performed, the thread is set to ready in the synchronizer. This is performed until de command is exit.
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • setIterationCount

        public void setIterationCount​(int iterationC)
        Specify the number of times that the iteration command is to be performed. We assume that this will be set correctly before iterate is called.
        Parameters:
        iterationC - Number of times the iteration has to be performed.