Code example for Striped

Methods: getsleep

0
 
    private Striped<Semaphore> stripedSemaphores = Striped.semaphore(10, 3);
    private Semaphore semaphore = new Semaphore(3);
 
    public void stripedConcurrentAccess(String url) throws Exception {
        Semaphore stripedSemaphore = stripedSemaphores.get(url);
        stripedSemaphore.acquire();
        try { 
            //Access restricted resource here 
            Thread.sleep(25);
        } finally { 
            stripedSemaphore.release();
        } 
    } 
 
    public void nonStripedConcurrentAccess(String url) throws Exception {
        semaphore.acquire();
        try { 
            //Access restricted resource here 
            Thread.sleep(25);