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
107
votes
5 answers

How to sync with a remote Git repository?

I forked a project on github, made some changes, so far so good. In the meantime, the repository I forked from changed and I would like to get those changes into my repository. How do I do that ?
George Profenza
  • 50,687
  • 19
  • 144
  • 218
106
votes
1 answer

Loop doesn't see value changed by other thread without a print statement

In my code I have a loop that waits for some state to be changed from a different thread. The other thread works, but my loop never sees the changed value. It waits forever. However, when I put a System.out.println statement in the loop, it suddenly…
Boann
  • 48,794
  • 16
  • 117
  • 146
106
votes
6 answers

Symbolic links and synced folders in Vagrant

I want to use Vagrant to provide a common development environment to my team. The hosts are completely different: Some use OS X, some Linux, and some Windows. Some use VMware, some use VirtualBox. Inside of the VM we want to run Linux. So far,…
Golo Roden
  • 140,679
  • 96
  • 298
  • 425
105
votes
31 answers

NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN error

After updating Android Studio and Gradle to 3.5, I now get this error: NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN I changed the Gradle version in build-gradle back to 3.4.2 but it didn't help.
Farhad Farzin
  • 1,239
  • 2
  • 9
  • 12
105
votes
10 answers

Two way sync with rsync

I have a folder a/ and a remote folder A/. I now run something like this on a Makefile: get-music: rsync -avzru server:/media/10001/music/ /media/Incoming/music/ put-music: rsync -avzru /media/Incoming/music/…
mwm
  • 1,897
  • 2
  • 15
  • 21
105
votes
10 answers

Why is synchronized block better than synchronized method?

I have started learning synchronization in threading. Synchronized method: public class Counter { private static int count = 0; public static synchronized int getCount() { return count; } public synchronized setCount(int count)…
Sabapathy
  • 1,613
  • 3
  • 18
  • 30
103
votes
18 answers

Make Requests in Sequential Order Node.js

If I need to call 3 http API in sequential order, what would be a better alternative to the following code: http.get({ host: 'www.example.com', path: '/api_1.php' }, function(res) { res.on('data', function(d) { http.get({ host:…
Howard
  • 19,215
  • 35
  • 112
  • 184
93
votes
16 answers

Are C++ Reads and Writes of an int Atomic?

I have two threads, one updating an int and one reading it. This is a statistic value where the order of the reads and writes is irrelevant. My question is, do I need to synchronize access to this multi-byte value anyway? Or, put another way, can…
theschmitzer
  • 12,190
  • 11
  • 41
  • 49
88
votes
7 answers

Java synchronized block vs. Collections.synchronizedMap

Is the following code set up to correctly synchronize the calls on synchronizedMap? public class MyClass { private static Map> synchronizedMap = Collections.synchronizedMap(new HashMap>()); public void…
Ryan Ahearn
  • 7,886
  • 7
  • 51
  • 56
87
votes
8 answers

How do determine if an object is locked (synchronized) so not to block in Java?

I have a process A that contains a table in memory with a set of records (recordA, recordB, etc...) Now, this process can launch many threads that affect the records, and sometimes we can have 2 threads trying to access the same record - this…
Shaitan00
  • 1,311
  • 2
  • 12
  • 23
86
votes
15 answers

How to use Git on Android?

I have a desktop application using git for synchronization. I have also an android application which do the same as the desktop, but I don't know how to do the synchronization part on it. I haven't found any implementation of git on android. I found…
Dave
  • 863
  • 1
  • 7
  • 4
84
votes
1 answer

What are atomic operations for newbies?

I am a newbie to operating systems and every answer I've found on Stackoverflow is so complicated that I am unable to understand. Can someone provide an explanation for what is an atomic operation For a newbie? My understanding: My understanding…
82
votes
9 answers

pthreads mutex vs semaphore

What is the difference between semaphores and mutex provided by pthread library ?
cppdev
  • 6,833
  • 13
  • 40
  • 45
81
votes
8 answers

When is a condition variable needed, isn't a mutex enough?

I'm sure mutex isn't enough that's the reason the concept of condition variables exist; but it beats me and I'm not able to convince myself with a concrete scenario when a condition variable is essential. Differences between Conditional variables,…
80
votes
4 answers

Is multi-thread output from System.out.println interleaved

If multiple threads call System.out.println(String) without synchronization, can the output get interleaved? Or is the write of each line atomic? The API makes no mention of synchronization, so this seems possible, or is interleaved output prevented…
Ellen Spertus
  • 6,576
  • 9
  • 50
  • 101