Skip to main content
Filter by
Sorted by
Tagged with
1 vote
2 answers
766 views

I'm trying to get a grasp on concurrency in Java, I've made this simple code that prints the letters of the alphabet : public static void main(String[] args) throws IOException, InterruptedException, ...
Mit94's user avatar
  • 1,104
1 vote
1 answer
127 views

In method acquire, node.prev is updated by node.setPrevRelaxed(t). It actually calls unsafe.putReference which does not ensure the visibility. final void setPrevRelaxed(Node p) { // for off-queue ...
Ander's user avatar
  • 66
0 votes
1 answer
2k views

We have following scenario where we have a class having two method and shared between multiple threads. public class Response { Map <String, APIResponse> requestIdToResponse = new ...
Rahul Tokase's user avatar
  • 1,228
0 votes
2 answers
385 views

I have a use case for high concurrent writes to an AtomicLong variable. I just need to set current epoc time in this variable. What would be the fastest way to do so? Is LongAccumulator.accumulate a ...
Manas Saxena's user avatar
  • 2,385
0 votes
0 answers
41 views

For a stock market algorithm, I am implementing an observable pattern for handling quotes. The "observers" are a list of triggers. The issue, is that this list can change (add a trigger, ...
Ethan Solomon's user avatar
0 votes
2 answers
2k views

On the Springboot-based application, I am creating a thread to finish a batch job and returning back immediately. Now, I need to forcefully kill the thread in some scenarios like a timeout. Can anyone ...
Prabhat Kumar's user avatar
1 vote
1 answer
798 views

Say I have a service that tries to load the data from DB, if data does not exist in DB, It tries to load from master DB and if it is not found there as well it will try to fetch from another API. This ...
shaleen madlapure's user avatar
0 votes
1 answer
389 views

I am writing a program which uses a CompletionService to run threaded analyses on a bunch of different objects, where each "analysis" consists of taking in a string and doing some ...
Theo's user avatar
  • 115
1 vote
0 answers
309 views

I have a calculation heavy spring boot application that runs on an AWS t3.large EC2 instance, with 2 virtual CPUs. I have two steps in the calculation and for the first step, I intend to use ...
maheeka's user avatar
  • 2,113
1 vote
1 answer
509 views

I'm searching various alternatives for a write intensive application when it comes to selecting a Java data structure. I know that ONE data structure could not provide a single universal solution ...
Niko's user avatar
  • 850
1 vote
1 answer
578 views

I have following code: public final class Start { private static final CountDownLatch FINAL_THREAD = new CountDownLatch(1); private static String getValue() { System.out.println(&...
mgorniew's user avatar
0 votes
1 answer
633 views

What consistency behaviour can I expect from this modify method with a ConcurrentHashMap? // map is filled concurrently from multiple threads private final ConcurrentHashMap<String, Object> map =...
jhyot's user avatar
  • 4,064
1 vote
2 answers
954 views

I have a ScheduledExecutorService that has a pool size of 1 threads. If I schedule many tasks using that service with the same delay, is the order of scheduling preserved during the execution?
Wojtek's user avatar
  • 1,550
5 votes
2 answers
2k views

I'm not getting the rationale behind negative permits during initialization of Semaphore (java.util.concurrent.Semaphore). I do know that calls to release() method may eventually make Semaphore's ...
Tejaskumar's user avatar
5 votes
1 answer
3k views

concurrentHashMapInstance.compute("Name", (key, val) -> { modifyValWithComplexLogic(val); return val; }); is modifyValWithComplexLogic(val) (and the whole compute method) ...
J.J. Beam's user avatar
  • 3,171
0 votes
1 answer
40 views

I have the following test code for learning purposes, in which I am trying to run a producer and a consumer threads running endlessly on a blocking Q. For some reason which I cannot understand, the ...
dushkin's user avatar
  • 2,123
0 votes
1 answer
2k views

I've been playing with blocking queues and PriorityQueue, and it got me thinking. I can't see a good usecase for PriorityBlockingQueue. The point of a priority queue is to sort the values put into it ...
ykaganovich's user avatar
  • 15.1k
1 vote
1 answer
261 views

I'm receiving a sequence of messages, and I want to process them in their sequential order. Each message has a sequence number. There's a pool of threads receiving them. I want to put them into a ...
ykaganovich's user avatar
  • 15.1k
3 votes
1 answer
831 views

Is it possible to make Subscriber run on the same thread as the Publisher (synchronously)? I can use CompletableFuture, but it delivers only a single result. But what if I need many results delivered ...
Alex's user avatar
  • 197
1 vote
1 answer
821 views

I know that typically for producer/consumer pairs like this, a blocking queue should be used. What I want here is only to understand better memory consistency in Java, interaction between concurrent ...
scriptfoo's user avatar
  • 513
0 votes
2 answers
70 views

//Initially, I wanted to compare synchronized with Lock public class SynchronizedVSLock { static final Lock lock = new ReentrantLock(); static final int loopTime = 10; static final int ...
zishun eglusaxie's user avatar
1 vote
1 answer
353 views

To use a DelayQueue we need to implement the Delayed interface for the getDelay(TimeUnit unit) and compareTo() method and as per my understanding, the getDelay method will be called where the ...
user avatar
1 vote
1 answer
420 views

I have the following which works: var tasks = tasks.stream(a -> (Callable<Set<FinishedTask>>) () -> call(a)).collect(Collectors.toList()); I want to change the above code to use ...
nimo23's user avatar
  • 5,802
-1 votes
1 answer
1k views

I'm getting concurrent exception replacing string inside iterator. fun replaceValuesInURLString(allFieldsValues: HashMap<String, UserSelectedData>, urlString: String): String { var ...
Ragini's user avatar
  • 785
0 votes
1 answer
279 views

When i run my test cases with cucumber textNg on jenkins with maven not always bu sometimes it give it error java.util.concurrent.Ex. I need to use synchronized for my methods to work properly. I have ...
user avatar

1 2 3
4
5
29