Questions tagged [phaser]

Introduced in Java 7, Phaser is a reusable synchronization barrier, similar in functionality to CyclicBarrier and CountDownLatch but supporting more flexible usage.

Introduced in Java 7, Phaser is a reusable synchronization barrier, similar in functionality to CyclicBarrier and CountDownLatch but supporting more flexible usage.

Not to be confused with Phaser.io, which uses the tag .

29 questions
1
vote
0 answers

How to ensure runnables are executed in a sequential order using a phaser

I have a list of runnables which are being sent to a phaser for execution but they don't execute in the order they are called. For example, if I send two runnables to the phaser, it should print "testing 0 testing 1" but sometimes it…
user2731063
1
vote
1 answer

Where to use barrier pattern in java?

I've just read the javadoc about Phaser there and have a question about usage that class. The javadoc provides a sample, but what about real-life example? Where such a barrier implementation could be useful in practise?
user3663882
  • 6,957
  • 10
  • 51
  • 92
1
vote
1 answer

Phaser instances & Spring MVC

I have a spring @Controller that has a request mapping. When requests are sent to it it creates a deferred result and runs a method on a delegator class. In the…
jacomus
  • 51
  • 2
1
vote
1 answer

Phaser Class and Tiering

According to the javadoc, in Phaser class, Phasers may be tiered (i.e., constructed in tree structures) to reduce contention. Phasers with large numbers of parties that would otherwise experience heavy synchronization contention costs may instead…
MaheshVarma
  • 2,081
  • 7
  • 35
  • 58
0
votes
2 answers

Java parallel array transforming using Thread and Phaser does not work correctly

It takes m iterations to transform the array according to the rule: a[i]=(a[i-1]+a[i+1])/2 Also, according to the assignment, I must use Thread and Phaser. Using of Thread and Phaser is mandatory, and there is no way I can refuse to use them. For…
0
votes
1 answer

Multiple arrive() in java phaser

Assuming all threads work in phase 0 of java phaser then one thread make arrive(); arrive(); arriveAndAwaitAdvance(); will this thread be waiting for phaser to end phase 2 or 0?
karol wołonciej
  • 109
  • 1
  • 1
  • 10
0
votes
0 answers

Phaser using ThreadPool does not correctly arrive and wait. How can I fix this?

A repo with the basic idea of how I use the Phaser and the problem that I run into can be found here: https://github.com/hipy/phaser/tree/master/src I've been working on making a Dijkstra algorithm more efficient with ThreadPools using a Phaser. I…
hipy
  • 75
  • 4
0
votes
1 answer

Phaser phase value escapes

Given, a class with main method that initializes a Phaser, and creates (say)3 Threads to count phases on the same Phaser. public class PhaserDemo2 implements Runnable { private static Phaser CLASS_PHASER; private static int COUNTER; …
soufrk
  • 825
  • 1
  • 10
  • 24
0
votes
1 answer

"Parties" as they relate to java's Phaser object

I am using a Phaser to attempt some synchronization in my java code. The documentation keeps mentioning registered/unregistered "parties"... what is a "party" in this context? Does it refer to a single thread of execution? I keep going over the…
Zack
  • 13,454
  • 24
  • 75
  • 113
0
votes
1 answer

Wait for completion of threadpool tasks using Phaser

I want to return from my executeTasks() method only after all the tasks submitted to the threadpool are finished. Please note that my thread pool has configurable threadpoolsize and uses SynchronousQueue as the backing queue, so my for loop proceeds…
uday
  • 142
  • 2
  • 12
0
votes
1 answer

java.util.concurrent.Phaser callback after phase termination

I investigate Phaser from java.util.concurrent package and I wrote code sample: public class ThreadsApp { public static void main(String[] args) { Phaser phaser = new Phaser(1); new Thread(new PhaseThread(phaser, "PhaseThread…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
0
votes
3 answers

Flexible CountDownLatch can't use Phaser because of limit

I'm receiving a big file, with N entries. For each entry, I'm creating a new thread. I need to wait for all the N threads to be terminated. At the beginning I was using Phaser, but its implementation is limited to 65K parties. So, is blowing up…
Perimosh
  • 2,304
  • 3
  • 20
  • 38
0
votes
0 answers

Phaser synchronizer example in Java

I've just read javadocs about phaser and now it's reasonobly to ask about whether the barrier implementation is applied in JDK itself (I consider JDK7). As the Phaser JavaDoc stated Phasers may also be used by tasks executing in a…
user3663882
  • 6,957
  • 10
  • 51
  • 92
0
votes
1 answer

Multiple Concurrency Issue with Future Object

I am trying to spawn off a handful of threads and place them in a List as they execute. As they complete their processing I would like to collect their results for presentation. That way I can have a list containing many threads and then once they…
Dan
  • 979
  • 1
  • 8
  • 29
1
2