JDSF Getting Started | 16bytes

JDSF Getting Started

Thu, 04/02/2009 - 09:44

Overview

Almost every programmer has got to the point where he worked with more than one thread, and then started synchronizing them. Today’s applications become not only multi threaded but also distributed, that is, an application can run on different processors and even different computers. Synchronizing such application is a very difficult task, and that is where our new project comes handy.

We provide a one class Monitor object that provides distributed getLock, releaseLock as well as wait-notify functionality.

Configuration

  • Add jdsf.jar into your classpath.
  • This API is based on JMS. Use the jms.provider JVM property to state the JMSLoader class being used (fully qualified name is needed)
  • Synchronizing

    Use org.jdsf.dl.LockObject to perform distributed synchronization.

  • To lock a critical section use LockObject.getLock("your string") at the beginning of the section.
  • To release a critical section use LockObject.releaseLock("your string") at the end of the section.

  • Please note that the lock can be created only on String objects at this time.

    Wait-notify

    Use org.jdsf.dl.LockObject to perform distributed wait-notify.

  • To wait for a notification use the LockObject.waitFor("your string");
  • To notify a single instance use the LockObject.notifyFor("your string");
  • To notify all instances use the LockObject.notifyAllFor("your string");



  • Please note that at the current version the wait and notify method do not lock/release the distributed monitor.

    An example use of JDSF can be found in the current release under the examples folder.

    Each String creates a lock only for the relevant String value, in this way multiple Distributed lock can be created.