Google Interview Question

Different ways of implementing

Interview Answer

Anonymous

Jun 16, 2012

Actually you were asked to provide some form of synchronization so that only 3 threads, each of them can upload a file ( so at the max 3 files at any time). We can use a semaphore initialized with 3 and threads that upload the file should acquire the semaphore before uploading and they should release the semaphore once finishing the upload so that other waiting thread if any can start uploading.

1