Tolik
Tolik

Reputation: 1

Can semaphores be declared and used inside a datastructure object (a self implemented queue for example)

As part of a homework assignment I'm implementing a queue that stores some files that need to be handled by workers(multiple threads write and read to the queue object), while implementing my queue class I wondered if I can declare and use the semaphores solely in the queue. By doing so I don't have to worry about mutual exclusion outside of my queue class. I know that I have other alternatives such as using synchronized blocks, but I only wonder about the theoretical part.

Upvotes: 0

Views: 28

Answers (0)

Related Questions