1,887 questions
-3
votes
1
answer
112
views
POJO class retains old values during multiple test execution
I am having pojo class with Lombok @data annotation. pojo classes are static in calling classes. So When I execute multiple selenium tests say test 1 and test 2, during test 2 execution, pojo fields ...
0
votes
4
answers
171
views
In a synchronized block, can I synchronize on a Collection of monitor objects?
I have a class that I want to make thread-safe. In it are these 2 functions :
public void add(String param1, String param2) {
// do something
}
public void clear() {
// do something else
}
I ...
-1
votes
1
answer
106
views
Stop reentrant synchronization only for specified function (or code) while waiting but permit reentrant synchronizing in another function
What is the best way to achieve following goals?
Let's say, given are two synchronized functions func1 and func2
public class xyz {
private Object x1 = new Object();
private boolean isWaiting = ...
-1
votes
1
answer
129
views
Java synchronization not working properly
I am trying to implement a custom HashMap for multithreading environment. Why is this giving inconsistent results? I think multiple threads are accessing the put method simultaneously.
class Main{
...
0
votes
1
answer
97
views
Unsure if there's a need using synchronized with concurrentMap
I have reviewed an implementation of map of maps in java and seen an excessive use of synchronized:
public class NestedMap<K1, K2, V> {
private Map<K1, Map<K2, V>> data = new ...
0
votes
2
answers
160
views
Can we avoid the use of Volatile in Singleton Pattern by making the getInstance() method synchronized in Java?
In most places, this is the implementation followed for Singleton Design Pattern.
It makes use of the keyword volatile to prevent the issue of partial object creation (establishes happens-before ...
-4
votes
1
answer
145
views
LeetCode 1116 Java Concurrency Issue, will waiting thread revisit code before? [closed]
Here is my code for the problem which works fine, however, when I change the while statement right under synchronized statement, it seems any thread that get the lock after notifyall() just continue ...
0
votes
1
answer
368
views
How to solve the resource temporarily unavailable problem when using YCSB to generate multiple clients to access rocksdb?
When testing the performance of Rocksdb with multiple column families using YCSB, I used four clients to load workloads on Rocksdb and wrote a script to execute four commands in parallel. The content ...
1
vote
1
answer
67
views
Unexpect Behavior with Multiple Java Threads and TreeMap.put()
When running the following code:
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
public final class ThreadTest {
int N = 4;
Map<Integer, Proxy> proxy = ...
-2
votes
1
answer
43
views
Race condition in ThreadPoolExecutor [duplicate]
What code must to do:
execute Bot#run synchronous.
What need to fix:
sharing resource (Bot.responseData or.. more) between other bots and threads.
Bot.run() execution stages:
http request -> ...
2
votes
3
answers
194
views
Why would I ever create a separate mutex/lock object?
I am modifying some concurrent code at work and recently read through Java's docs on Intrinsic Locks and Synchronization.
Given that every object has an intrinsic lock, why would I ever create a ...
0
votes
1
answer
26
views
How to verify the synchronization results of tsfle in Apache IoTDB when using `pipe`?
When I synchronize tsfile from Apache IoTDB server A to server B through pipe, how to verify the synchronization results, and how to know whether the synchronization is successful? What result ...
0
votes
1
answer
65
views
Multi-threaded Java application is behaving unexpectedly. Can someone point out the problem?
I have a simple class which does not behave as expected. I'd like to point out that this class is the whole application. I'll show the code, the output, and then ask my question.
import java.awt.Image;...
-1
votes
1
answer
93
views
Thread runs infinitely because `synchronized` does sync access to a field and 4 methods in a concurrency test with two threads
Things to Note:
I use JetBrain IntelliJ IDEA Community Edition.
My code relies on 3 short classes. Easy to read.
The original code runs as it is and produces the appropriate result. See image at ...
1
vote
1
answer
95
views
Why is the Synchronized Block invalidated?
As known that List is not thread-safe, I add synchronized to the code in 2 methods shown below.
1.
public class TestSyn
{
public static void main( String[] args ) throws InterruptedException
{
...