Multi Threading

Threading advantages

  1. Prioritization of different tasks.
  2. Break up long running tasks


  1. Expense of time slicing
  2. Synchronization issues, such as dead-lock, need to be managed
  3. Extra resources to store thread contexts

Java provides java.util.concurrent which has several useful classes described here

  • TimeUnit – easy way to convert between different time measures
  • Data Structures such as ConcurrentMap and CopyonWriteArray (makes a new array on set, update commands)
  • Queues like a BlockingQueue or a SynchronousQueue
  • Semaphore object for locking
  • Excecutor to create threads that can be managed by an ExcecutorService such as ScheduledExcecutorService. Think of an Executor Service of a way of managing Thread Pools
  • Callable (comparare to Runnable) except can return a result as a Future when calling submit() (compare to run())


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s