Questions tagged [synchronization]

Synchronization refers to using controls to maintain a coherent representation, either a group of processes running the same program (process synchronization), or representations of data (data synchronization).

In computer science, synchronization refers to one of two distinct but related concepts: synchronization of processes, and synchronization of data. Process synchronization refers to the idea that multiple processes are to join up or handshake at a certain point, so as to reach an agreement or commit to a certain sequence of action. Data synchronization refers to the idea of keeping multiple copies of a dataset in coherence with one another, or to maintain data integrity. Process synchronization primitives are commonly used to implement data synchronization.

-from Synchronization (computer science) - Wikipedia

12446 questions
80
votes
6 answers

How to synchronize or lock upon variables in Java?

Let me use this small and simple sample: class Sample { private String msg = null; public void newmsg(String x){ msg = x; } public String getmsg(){ String temp = msg; msg = null; return temp; …
Winter
  • 1,896
  • 4
  • 32
  • 41
74
votes
5 answers

Does lock() guarantee acquired in order requested?

When multiple threads request a lock on the same object, does the CLR guarantee that the locks will be acquired in the order they were requested? I wrote up a test to see if this was true, and it seems to indicate yes, but I'm not sure if this is…
Samuel Neff
  • 73,278
  • 17
  • 138
  • 182
71
votes
3 answers

Monitor vs Mutex in c#

Possible Duplicate: What are the differences between various threading synchronization options in C#? What is the difference between a Monitor and a Mutex in C#? When to use a Monitor and when to use a Mutex in C#?
Ajay
  • 9,947
  • 8
  • 32
  • 34
69
votes
6 answers

Collections.synchronizedList and synchronized

List list = Collections.synchronizedList(new ArrayList()); synchronized (list) { list.add("message"); } Is the block "synchronized (list){} " really need here ?
romsky
  • 864
  • 1
  • 8
  • 11
69
votes
5 answers

What is progress and bounded waiting in critical section?

I was reading Critical Section Problem from Operating System Concepts by Peter B. Galvin. According to it 1) Progress is : If no process is executing in its critical section and some processes wish to enter their critical sections, then only those…
66
votes
5 answers

How to duplicate a MySQL database on the same server

I have a large MySQL database, lets call it live_db, which I want to replicate on the same machine to provide a test system to play around with (test_db), including table structure and data. In regular intervals I want to update the test_db with the…
Christoph Grimmer
  • 4,210
  • 4
  • 40
  • 64
62
votes
10 answers

Concurrent threads adding to ArrayList at same time - what happens?

We have multiple threads calling add(obj) on an ArrayList. My theory is that when add is called concurrently by two threads, that only one of the two objects being added is really added to the ArrayList. Is this plausable? If so, how do you get…
Marcus Leon
  • 55,199
  • 118
  • 297
  • 429
62
votes
3 answers

Are LinkedBlockingQueue's insert and remove methods thread safe?

I'm using LinkedBlockingQueue between two different threads. One thread adds data via add, while the other thread receives data via take. My question is, do I need to synchronize access to add and take. Is LinkedBlockingQueue's insert and remove…
Steve Kuo
  • 61,876
  • 75
  • 195
  • 257
60
votes
1 answer

More iCloud Core Data synching woes

So, it finally happened. The worst case scenario for any independent iPhone developer occurred. Several users are reporting complete data loss after upgrading my app. iCloud Core Data sync is not working. My users are using this app partially to run…
Mundi
  • 79,884
  • 17
  • 117
  • 140
60
votes
20 answers

Synchronizing on String objects in Java

I have a webapp that I am in the middle of doing some load/performance testing on, particularily on a feature where we expect a few hundred users to be accessing the same page and hitting refresh about every 10 seconds on this page. One area of…
matt b
  • 138,234
  • 66
  • 282
  • 345
58
votes
13 answers

Android: How to get a modal dialog or similar modal behavior?

These days I'm working on simulating modal dialog in Android. I've googled a lot, there's much discussions but sadly there's not much options to get it modal. Here's some background, Dialogs, Modal Dialogs and Blockin Dialogs / AlertDialogs: How to…
fifth
  • 4,249
  • 9
  • 45
  • 62
58
votes
8 answers

Android build error: Unable to load 'javax.xml.bind.jaxbexception

I am a beginner in Android. I am not able to resolve this error in Android Studio. Whenever I run my application this error occurs. How do I fix it? Error: Unable to load class 'javax.xml.bind.JAXBException' Possible causes for this unexpected…
Hitesh rawal
  • 681
  • 1
  • 5
  • 4
58
votes
6 answers

Synchronising twice on the same object?

I was wondering if in Java I would get any odd behaviour if I synchronise twice on the same object? The scenario is as follows pulbic class SillyClassName { object moo; ... public void method1(){ synchronized(moo) { …
Omar Kooheji
  • 54,530
  • 68
  • 182
  • 238
58
votes
7 answers

How to synchronize two Subversion repositories?

My company has a subsidiary with a slow Internet connection. Our developers there suffer to interact with our central Subversion server. Is it possible to configure a slave/mirror for them? They would interact locally with the server and all the…
neves
  • 33,186
  • 27
  • 159
  • 192
57
votes
1 answer

Which std::sync::atomic::Ordering to use?

All the methods of std::sync::atomic::AtomicBool take a memory ordering (Relaxed, Release, Acquire, AcqRel, and SeqCst), which I have not used before. Under what circumstances should these values be used? The documentation uses confusing “load” and…
yonran
  • 18,156
  • 8
  • 72
  • 97