60 votes

No central database

Plenty of sensitive information gets stored in databases. In fact, a central database is probably the most secure way to store this data. Large enterprise databases have tons of functionality to do ...
user avatar
  • 12.6k
38 votes

No central database

You need to back up a couple steps and, in consultation with your client, work out a threat model. (Yes, that's a link to a 600-page book; yes, I am seriously recommending you read the entire thing.) ...
user avatar
  • 2,566
36 votes

Is "releases mutexes in reverse order" required to make this deadlock-prevention method work?

For a deadlock (more specifically, a circular wait) to occur, there needs to be a circular chain of n ≥ 2 mutexes (or other exclusively lockable resources) R1, R2, …, Rn such that, for each k from 1 ...
user avatar
19 votes

How to justify using await instead of .Result() or .Wait() in .NET Core?

You have missed the point of async/await It wasn't created to frustrate developers with deadlocks. It was created to free up Processing power while we wait for a non CPU based task to complete. The ...
user avatar
  • 64.5k
15 votes

Best way to synchronize data between two different databases

This is pretty much what I have been doing or a living the past few years, and my gut instinct is that the time to read 500,000 items from the source database and sync in the destination will not take ...
user avatar
13 votes
Accepted

Can multiple synchronized methods in same object run concurrently

In Java, synchronized locks are re-entrant. Or in other words if your thread already holds the lock on an object it doesn't have to wait on itself.
user avatar
12 votes

What are some approaches used in financial applications to prevent deposit/withdrawal sync problems?

Transactions A transaction wraps all of the required steps for a particular business operation and guarantees that either all of the steps succeed or they all rollback to the original state in the ...
user avatar
11 votes

Is "releases mutexes in reverse order" required to make this deadlock-prevention method work?

For a deadlock to occur a system has to have several properties simultaneously. Wikipedia has some more details on this but for short: Mutual Exclusion Incremental Acquisition No preemption Circular ...
user avatar
  • 15.4k
10 votes

Can multiple synchronized methods in same object run concurrently

If you read carefully the documentation of synchronized you will find that it is explicitly stated that once a thread has acquired a lock, it is allowed to re-acquire it as many times as it pleases. ...
user avatar
  • 31.4k
10 votes

Why do we need read locks in read-write locks?

A read lock allows multiple concurrent readers of some data, but it prevents readers from accessing the data while a writer is in the middle of changing it. That ensures that a reader will never see a ...
user avatar
9 votes
Accepted

Combining asynchronous and synchronous programming

Promises were made to solve problems like this; they work really well in functional languages (I've personally used them extensively in Javascript, where curiously jQuery actually has the worst ...
user avatar
  • 246
9 votes
Accepted

Data from devices with unreliable clocks

There's actually quite a bit you can do to recover something close to the actual time of most of your events. Android gives you a few useful tools to work with, notably broadcast intents sent when ...
user avatar
  • 19.9k
9 votes

Is "releases mutexes in reverse order" required to make this deadlock-prevention method work?

Let's have a look at the simplest form of deadlock: the kiss of death of two processes trying to acquire 2 mutexes: (1) | (2) Lock mutex A (success) | Lock mutex ...
user avatar
  • 67.7k
8 votes

No central database

One option to do the synchronization would be to do it peer-to-peer. This will still require a central server, but that server won't handle any of the data. When a device goes online, a central ...
user avatar
  • 22.8k
8 votes

Do critical section and atomicity imply each other?

Atomicity should be understood to mean that the thing it refers to (a transaction, an operation, etc.) is all-or-nothing. There is no defined mechanism to observe partial results. For a database ...
user avatar
7 votes

What will you do if multiple users access your application at the same time?

This is a really broad question, since concurrency issues are handled in a variety of ways in complex system. For example a synchronized block in Java is only locked for other threads in the same ...
user avatar
  • 54.7k
6 votes
Accepted

Real time data synchronization techniques between two systems

First, as the comments point out, you aren't really talking about realtime here -- that has a pretty strict definition and implies lots of stuff that isn't really on the table. You are talking about ...
user avatar
6 votes
Accepted

How much time should you allow for clock skew?

You need to do this based on what you actually see in your system. The two basic approaches are to do it once or to make your code adjust on the fly. The first is obviously a lot easier to do but ...
user avatar
  • 1,242
6 votes

Best way to synchronize data between two different databases

The data sync would be much better and faster, if it can be done on the basis of some kind of delta identifier or flag. Basically, you should update the target db data rows only when it is out of sync ...
user avatar
  • 366
6 votes
Accepted

How to resolve data-binding efficiently

This is either fundamentally meaningless or you've left out an important detail. Your diagrams give each node 3 states: ● Unchanged, don't propagate ◌ Just now changed and in need of propagation ○ ...
user avatar
5 votes
Accepted

What's the best way to synchronise an event over multiple processes?

According to EBU Recommendation R37: “The relative timing of the sound and vision components of a television signal” states that end-to-end audio/video sync should be within +40ms and -60ms (audio ...
user avatar
5 votes

Non-synchronized method that calls synchronized methods only

That depends. Could there be problems if something happens between the calls to A and B? If so, then C should be synchronized. public class SomeClass{ private int i; public synchronized void ...
user avatar
  • 5,632
5 votes

No central database

Make it somebody else's problem. Store the data locally in each app, then give users the option to enable synchronization using their own account with a third-party service (Dropbox, Google Drive, ...
user avatar
5 votes

A simple approach for data synchronisation

Syncing between multiple clients is a very complext task. Let's not call it syncing, let's call it bash transaction processing. Let's get rid of "last server update timestamp", let's just every ...
user avatar
5 votes

Bi-directional sync of 2 different APIs

Welcome to the world of integration. The hardest thing about it is how poorly most vendors understand what you need and the resulting gaps in their interfaces. In this case you seem to have a really ...
user avatar
  • 22.1k
5 votes
Accepted

Best practices for app-cloud synchronization of database representation

You are trying to create a distributed eventually-consistent system. Those are inherently complicated. It's understandable that you are having difficulty coming up with a good solution because there ...
user avatar
  • 123k
5 votes

When does a *fixed delay* make sense?

Yes. To delay to give time for completion prior to checking. Yes. To animate, because humans see in the order of ~80hz. Yes. To throttle, running at 100% isn't always the right option. No. There is ...
user avatar
  • 15.4k
5 votes

Why do we need read locks in read-write locks?

An update lock is an exclusive lock, that is, only one lock can be held at a time. It is used to prevent concurrent updates. A read lock is a shared lock, multiple readers can held a read lock ...
user avatar
  • 12.2k
5 votes
Accepted

One producer - multiple consumers queue, best way to guard against rare duplicates?

[As discussed in comments: OP is moving towards an actual queue implementation - a genuine single-producer multiple-consumer pattern.] Here's one approach based on a queue: Have a map from underlying ...
user avatar
  • 661
4 votes

Conflict resolution for two-way sync

I guess there is no standard way to do it, each system uses their own policies for the conflict resolution. I made some simulations using two devices, computer and phone, and Google Spreadsheet to ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible