Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

EX NO: 5 IMPLEMENTATION OF VARIOUS LOCKING AND

SYNCHRONIZATION MECHANISMS FOR CONCURRENT QUEUES

AIM:
To implement various Locking and Synchronization mechanisms for Concurrent Queues

ALGORITHM:
Step.1: Initialize the Queue size.
Step.2: The size of element is initialized by the function SharedObject ()
Step.3: In the main Demo () class, the object is created,
produce () and consume() function is called.
Step.4: Produce () and Consume () are the function used to process the
Element in the Queue.
Step.5: In the produce () function, Checks whether the Queue is full,
Step.6: In the try () block, it wait for seconds until queue is full.
Step.7: In the catch () block, it throws an exception,
Otherwise, it produce the data.
Step.8: In the consume () function, Checks whether the Queue is empty,
Step.9: In the try () block, it wait for seconds until queue is empty,
Step.10: In the catch () block, it throws an exception,
Otherwise, it consumes the data.
Step.11: Random () function is used, to generate the random elements,
Where the elements can be produced and consumed.
Step.12: End the process.

RESULT:
Thus, the program to implement various Locking and Synchronization mechanisms for
Concurrent Queues is successfully executed.

You might also like