Class WorkerThread

  extended by java.lang.Thread
      extended by vanetsim.simulation.WorkerThread
All Implemented Interfaces:

public final class WorkerThread
extends java.lang.Thread

This thread is meant to run parallel with multiple others to gain advantage of multiple CPUs. All simulation tasks are initiated from this class!

Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
Field Summary
Fields inherited from class java.lang.Thread
Constructor Summary
WorkerThread(Region[] ourRegions, int timePerStep)
          The main constructor for the worker thread.
Method Summary
 void addChangedRegion(int i)
          Adds a region to the list of changed region (so that it gets updated).
 void run()
          The main method.
 void setBarriers(java.util.concurrent.CyclicBarrier barrierStart, java.util.concurrent.CyclicBarrier barrierDuringWork, java.util.concurrent.CyclicBarrier barrierFinish)
          Set CyclicBarriers for thread synchronization.
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public WorkerThread(Region[] ourRegions,
                    int timePerStep)
The main constructor for the worker thread. Don't use any other constructor inherited from the Thread class as all parameters are essential!

ourRegions - the regions which are assigned to us.
timePerStep - the time in milliseconds for one step
Method Detail


public void setBarriers(java.util.concurrent.CyclicBarrier barrierStart,
                        java.util.concurrent.CyclicBarrier barrierDuringWork,
                        java.util.concurrent.CyclicBarrier barrierFinish)
Set CyclicBarriers for thread synchronization.

barrierStart - the barrier for starting
barrierDuringWork - the barrier after adjusting the speed
barrierFinish - the barrier after completing all tasks


public void addChangedRegion(int i)
Adds a region to the list of changed region (so that it gets updated).

i - the number of the region in this thread


public void run()
The main method. All simulation is initiated from here!

Specified by:
run in interface java.lang.Runnable
run in class java.lang.Thread