Questions tagged [thread-synchronization]

In a multi-threaded environment thread synchronization is used to coordinate access to shared resources such as file handles, network connections, and memory

In a multi-threaded environment thread synchronization is used to coordinate access to shared resources such as file handles, network connections, and memory

References

645 questions
0
votes
2 answers

How to synchronise methods of Firebase

In my Firebase database, I have two children let Child1, Child2. Child1 contains profile information of users as Root/Child1/Uid-User(x)/User_details. Child2 contains transactions done by users as Root/Child2/Uid-User(x)/Transaction_details. I want…
0
votes
2 answers

Android: Task sequential on a thread in JAVA

Have use case where BroadcastReceiver action events received and need execute them in sequential order. Here as below Event1 and Event2 can be received back to back. Event1 work has to be completed and then Event2 work should be started. How to make…
NitZRobotKoder
  • 1,046
  • 8
  • 44
  • 74
0
votes
1 answer

java:inefficiency of synchronized methods

I was going through this program and could not make much sense of it. class Q { int n; synchronized int get() { System.out.println("Got: " + n); return n; } synchronized void put(int n) { this.n = n; …
0
votes
3 answers

having issues creating a WriteFiles with a multithreaded application

I'm having some issues trying to create a thread constructor that will accept a file name and a 2-d array of data to be written to the file. The thread run method is suppose to write that 2-d array to the file and then instantiate this thread for…
0
votes
1 answer

Thread pool issue in java

HI the following code is used in a application threadPool.shutdown(); while (!threadPool.awaitTermination(10, TimeUnit.SECONDS)) { logger.info("Waiting for " + (threadPool.getQueue().size() + threadPool …
siva
  • 5
  • 1
  • 6
0
votes
1 answer

How to detect a thread synchronization in a program in my LLVM pass?

I'm trying to measure how much time a program spends in its synchronized parts e.g. critical sections protected by locks (or any other form of concurrency control). I'm confused on how to do it and how to detect concurrency control methods in a…
0
votes
0 answers

ConcurrentModificationException thrown when setting a view to visible

I have two ListFragments and 6 views all set with onDragListeners. If a user drags one of these 6 views onto the ActionBar, a ConcurrentModificationException is thrown. This is because I have set each of these 6 views to listen for…
0
votes
0 answers

stop multiple threads from acessing a variable

I'm using flask for a web application, it was all going well till I had to deal with multiple requests( I am using threaded=true) My problem is if I get two parallel requests then flask will create two threads and they will try to create a file with…
Bad_Coder
  • 1,019
  • 1
  • 20
  • 38
0
votes
1 answer

Start a new CountDownTimer inside a run method

I am new to android development, and I am trying to create a little game. I have my first CountDownTimer created by the constructor in my GameView subclass of SurfaceView. What I should do in order to pass on the next level, is call the cancel() of…
ldg
  • 450
  • 3
  • 7
  • 27
0
votes
0 answers

Thread vs Thread?

Suppose that I have a process P1 with 4 threads, another process P2 with 4 threads and I have 4 cores. The cores are busy with my P1 process' threads. Suppose that a thread with higher priority from P2 comes to the scene, what happens then? Does…
0
votes
0 answers

Synchronized methods vs SwingUtilities.invokeLater

In my project I have a class extending a JFrame. It exposes some methods wich are used by many threads. I am wondering what is the best approach between these two in order to avoid concurrency issues: public synchronized void doStuff1(final String…
Svech87
  • 88
  • 1
  • 1
  • 7
0
votes
1 answer

What is advantage of using synchronized threads?

I have a doubt regarding synchronized threads. See the below code #include #include #include #include #include #include int a=0; sem_t s1, s2; void* t1handler(void *data) { …
Ramana Reddy
  • 369
  • 1
  • 8
  • 28
0
votes
2 answers

Thread synchronization with Monitor.Pulse NOT working as expected

I have two methods, first() and second() and I assigned them to two threads. Following are my second and first methods public void first() { lock (this) { Monitor.Wait(this); …
user786
  • 3,902
  • 4
  • 40
  • 72
0
votes
1 answer

Why getDefaultDisplay().getSize(Point size) is updating its argument instead of returning a value?

Its actual implementation is, public void getSize(Point outSize) { synchronized (this) { updateDisplayInfoLocked(); mDisplayInfo.getAppMetrics(mTempMetrics, mDisplayAdjustments); outSize.x = mTempMetrics.widthPixels; …
rehman_00001
  • 1,299
  • 1
  • 15
  • 28
0
votes
1 answer

Is JVM string pool thread local? Will it cause any issue with this use case?

Many articles on internet specifies that using String.intern() in multi threading is bad but I really could not understand why it is bad.Using String.intern() always return a unique string from string pool,isn't it? If that is not the case then Is…