semaphore « concurrency « Java Thread Q&A

Home
Java Thread Q&A
1.concurrency
2.Development
3.Exception
4.Notify
5.Operation
6.Socket
7.State
8.synchronize
9.Thread Safe
10.ThreadPool
Java Thread Q&A » concurrency » semaphore 

1. CountDownLatch vs. Semaphore    stackoverflow.com

Is there an advantage to using java.util.concurrent.CountdownLatch instead of java.util.concurrent.Semaphore? As far as I can tell the following fragments are almost equivalent: 1:

final Semaphore sem = new ...

2. What is mutex and semaphore in Java ? What is the main difference?    stackoverflow.com

What is mutex and semaphore in Java ? What is the main difference ?

3. Lock that can be transferred from one thread to another    stackoverflow.com

I am looking for a type of lock where the thread that holds the lock can pass it on to another thread of its choosing. Here is why I want it:

  • I have ...

4. java: executors + tasks + locks    stackoverflow.com

Suppose I have an ExecutorService (which can be a thread pool, so there's concurrency involved) which executes a task at various times, either periodically or in response to some other condition. ...

5. How can I write a semaphore in Java which prioritizes previous successful applicants?    stackoverflow.com

I have a need for a single-permit semaphore object in my Java program where there is an additional acquire method which looks like this:

boolean tryAcquire(int id)
and behaves as follows: if the ...

6. java concurrency: lightweight nonblocking semaphore?    stackoverflow.com

I have a situation where I have a callback that I want to execute once. For the sake of argument let's say it looks like this:

final X once = new X(1);
Runnable ...

7. Understanding ReusableBarrier Problem (from 'Little Book of Semaphores')    stackoverflow.com

The problem statement is as follows: Often a set of cooperating threads will perform a series of steps in a loop and synchronize at a barrier after each step. For this application we ...

8. BoundedSemaphore semaphore vs standard Mutex    stackoverflow.com

Does anyone know which of the two locking constructs is faster? I have:

private static final Object mutex = new Object();

void method() {
    synchronized(mutex) {
     ...

9. Java read & write lock requirement, with lock and release from different threads    stackoverflow.com

I'm trying to find a less clunky solution to a Java concurrency problem. The gist of the problem is that I need a shutdown call to block while there are still worker ...

10. How and why can a Semaphore give out more permits than it was initialized with?    stackoverflow.com

I am reading the book Java Concurrency in Practice. In a section about java.util.concurrent.Semaphore, the below lines are present in the book. It is a comment about its implementation of "virtual ...

11. How to code the dining Philosophers in Java using semaphores?    stackoverflow.com

I have to code a solution to the dining philosophers problem in Java using semaphores. The semaphore is done "by hand" creating a semaphore class. And looks like this:

package principal;
public class ...

12. Solving Readers/Writers using java Semaphores    stackoverflow.com

So, it's a classical concurrency problem we're (Me and my colleague) facing here. We weren't lazy, We brought some relevant code in order for you to help us properly. We have two ...

13. How to implement a Binary Semaphore Class in Java?    stackoverflow.com

I can see how a "standard" Semaphore Class can be implemented in Java. However, I cant see how to implement a Binary Semaphore Class in Java. How does such implementation work? ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.