Semaphores explained -- A Java approch
Semaphore can be considered as a variable or Data Structure that can be used to archive mutual exclusion in a Parallel Programming environment. One good real life example to explain this is the tablet mechanism that is used in old railway system. Where when a train enters a Train Station it need to get a tablet from the Station master to proceed to the next station. When the train get the tablet that means there will be no other train in the railway track till it reaches the next station. When The train arrived to the next station it must give back the tablet to the station master so that he can signal the station that train has come from that line is cleared now (line is clear ) So getting a tablet is like acquiring a lock in the train line so that other trains that are in need of acquiring the line need to wait till the train reaches the next station and release the lock ( give the tablet back). This signal system still in use in Sri Lanken Railway line in some parts where the...