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

REST web services: synchronous or asynchrous?

What is the default behavior of REST web services - synchronous or asynchronous? If it's synchronous then can we create asynchronous?
Ajit
  • 957
  • 1
  • 8
  • 24
38
votes
6 answers

What is the difference between a synchronized method and synchronized block in Java?

What is the difference between a synchronized method and synchronized block in Java ? I have been searching the answer on the Net, people seem to be so unsure about this one :-( My take would be there is no difference between the two, except that…
Geek
  • 23,089
  • 20
  • 71
  • 85
37
votes
9 answers

What's the best way to synchronize times to millisecond accuracy AND precision between machines?

From what I understand, the crystals on PC's are notorious for clock skew. If clocks are always skewing, what is the best way to synchronize clocks between machines with millisecond accuracy and precision? From what I've found, NTP and PTP are…
PiNoYBoY82
  • 1,618
  • 2
  • 14
  • 17
37
votes
6 answers

Should you synchronize the run method? Why or why not?

I have always thought that synchronizing the run method in a java class which implements Runnable is redundant. I am trying to figure out why people do this: public class ThreadedClass implements Runnable{ //other stuff public synchronized…
MHP
  • 385
  • 1
  • 4
  • 8
37
votes
9 answers

Synchronizing on an Integer value

Possible Duplicate: What is the best way to increase number of locks in java Suppose I want to lock based on an integer id value. In this case, there's a function that pulls a value from a cache and does a fairly expensive retrieve/store into the…
Steve B.
  • 55,454
  • 12
  • 93
  • 132
37
votes
6 answers

What is the use of Collections.synchronizedList() method? It doesn't seem to synchronize the list

I am trying to add String values to an ArrayList using two threads. What I want is that while one thread is adding the values the other thread should not interfere so I have used the Collections.synchronizedList method. But it appears that if I…
Fullstack Guy
  • 16,368
  • 3
  • 29
  • 44
37
votes
6 answers

How to acquire a lock by a key

What is the best way to prevent concurrent update of one record in a key-value set without locking the entire set? Semantically, I'm looking for some kind of locking by a key (ideally, Java implementation, but not necessarily): interface LockByKey…
user1128016
  • 1,438
  • 3
  • 16
  • 17
37
votes
10 answers

Java Synchronization Not Working as Expected

I have a "simple" 4 class example that reliably shows unexpected behavior from java synchronization on multiple machines. As you can read below, given the contract of the java sychronized keyword, Broke Synchronization should never be printed from…
Luke
  • 3,742
  • 4
  • 31
  • 50
36
votes
4 answers

How to share semaphores between processes using shared memory

I have to synchronize N client processes with one server. These processes are forked by a main function in which I declared 3 semaphores. I decided to use POSIX semaphores but I don't know how to share them between these processes. I thought that…
Sicioldr
  • 543
  • 3
  • 7
  • 13
36
votes
2 answers

Automatically keep a secondary repo in sync with a primary repo?

We have a two tier setup. We have a primary repository (called 'primary' below). And a secondary repository (called 'secondary' below) that was created like so: $ git clone --bare --shared $REPO_A/primary secondary.git People working on the…
George Hawkins
  • 37,044
  • 7
  • 30
  • 43
36
votes
3 answers

How to add programmatically a custom account in android?

I am trying to create an account for my app, where I will be able to have my contacts against my account like facebook, viber, whatsapp etc. I want my account to be visible in the account section of the settings also. Any ideas? I have googled a…
user3673503
  • 385
  • 2
  • 6
  • 14
36
votes
14 answers

Is there a solution to automatically synchronize Emacs org-mode with one of the web based todo services?

Org-mode is amazing. I like its power and simplicity. However, sometimes I need access to my tasks in places where I don't have the necessary setup. Is there a way to synchronize my org agenda with one of the better web based todo services like RTM,…
Tom
  • 361
  • 1
  • 3
  • 3
36
votes
3 answers

Command-line/API for Schema Compare in SSDT SQL Server Database Project?

In Visual Studio 2012, we have Schema Compare in SSDT's SQL Server Database Project (DbProject) project which helps Compare source versus target Update target to make it the same as source Where Source and target can be either a database, a…
Nam G VU
  • 33,193
  • 69
  • 233
  • 372
36
votes
5 answers

Correct way to synchronize ArrayList in java

I'm not sure if this is the correct way to synchronize my ArrayList. I have an ArrayList in_queue which is passed in from the registerInQueue function. ArrayList in_queue = null; public void registerInQueue(ArrayList in_queue) { …
bob
  • 407
  • 1
  • 5
  • 9
36
votes
5 answers

Multiplayer Game Synchronization

I've a server/client architecture implemented, where all state changes are sent to the function, validated and broadcasted to all clients connected. This works rather well, but the system does not maintain synchronization between the client…
Kasper Holdum
  • 12,993
  • 6
  • 45
  • 74