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
4
votes
4 answers

Does the static ConcurrentHashmap needs external synchronisation

Does the static ConcurrentHashmap need to be externaly synchronized using synchronize block or locks?
Vishal
  • 55
  • 1
  • 4
4
votes
2 answers

Synchronization of two method which work on ArrayList

I have Sum class, Creator class, Item class and Main. The Creator creates random Items and adds them to an ArrayList which is in the Item class. The Sum class reads items and sums the weight of all. In the Main class I start in multiple threads…
4
votes
1 answer

How to copy vs code settings from one github account to another

I have two github accounts and currently vs code settings is synced with one account but I want copy the settings to the second github account and sync from there. How to do it? Thanks!
r ne
  • 621
  • 7
  • 19
4
votes
2 answers

How to stop threads when one of them finds a prime number

When a prime number is found, I have to stop it. When I use synchronized before the while, only one thread process will occur. However, multiple thread operations should occur, but all should stop when prime is found. The initial value of i in the…
4
votes
3 answers

How do I reverse set_value() and 'deactivate' a promise?

I have a total n00b question here on synchronization. I have a 'writer' thread which assigns a different value 'p' to a promise at each iteration. I need 'reader' threads which wait for shared_futures of this value and then process them, and my…
MMagique
  • 41
  • 3
4
votes
2 answers

complex threading with OpenMP

I need to switch from boost::thread to OpenMP because boss says so. The problem is quiet simple: the result of a simulation is written to disk every 5 iteration (int it = 5,10,15...). For the sake of simplicity, suppose I have an 8-core CPU. I…
JohnC
  • 51
  • 1
  • 2
4
votes
2 answers

How to synchronize between multiple async processes in Python?

I have an async http webs service using fastapi. I am running multiple instances of the same service on the server on a different port and I have an nginx server in front so I can utilise them all. I have a particular resource I need to protect that…
4
votes
2 answers

PHP / MySQL Conceptual Database 'Sync' question

I am working on a PHP class implementing PDO to sync a local database's table with a remote one. The Question I am looking for some ideas / methods / suggestions on how to implement a 'backup' feature to my 'syncing' process. The ideas is: Before…
grep
  • 3,986
  • 7
  • 45
  • 67
4
votes
2 answers

Java: A synchronized method is accessed several times by reflection?

I've a very odd behaviour on one of my class, and don't know exactly what is happening. 1) I've a JSP which sends a request to a Servlet with AJAX 2) The servlet process this request in the following way: - It makes a reflection of a class, and…
4
votes
3 answers

Static fields in an ASP.NET Webservice

Is a static variable in a webservice shared between all running invocations of the webservice on a server? In my case I want a server-wide sync-lock, and I beleive I can accomplish that with a single private static Object syncHandle = new…
C. Ross
  • 31,137
  • 42
  • 147
  • 238
4
votes
3 answers

JavaScript Sort an Array, but keep a second array in sync

I am trying to sort one array, but have a second array stay in sync with the first. Example: var a1 = ["human", "animal", "plant"]; var a2 = ["person", "beast", "nature"]; a1.sort(); After the sort I need to arrays to look like this: a1 =…
Sarathi
  • 1,023
  • 1
  • 14
  • 22
4
votes
2 answers

Need help in understanding Thread wait and notify

class Semaphore { private int count=100; public Semaphore(int n) { this.count = n; } public synchronized void acquire() { while(count == 0) { try { wait(); } catch (InterruptedException e) { …
Pawan
  • 31,545
  • 102
  • 256
  • 434
4
votes
0 answers

Locking a resource for update process (ReadWrite lock) In Container Enviroment

I have a python application that accesses a database (PostgreSQL) with a master data in order to search within it - done by a search threads (A 150 mb database). Once a day there is an update process that updates the database (drops and loads a new…
sborpo
  • 928
  • 7
  • 15
4
votes
2 answers

C# Syncing data between SQLite and SQL Server

I'm designing a small piece of software for a company. Basically, they need to manage a large list of items. Edit, delete, and so on. Basically, I'm storing the data INITIALLY in SQLite locally on their computer. Once they get done modifying the…
Thomas
  • 41
  • 1
  • 2
4
votes
2 answers

visibility of side effects when creating and joining threads

When are writes that are performed by one thread visible to a different thread when there are no synchronized blocks and no volatile variables? Here is a simplified quicksort example: int middle = partitionForTheFirstTime(array); Thread t = new…
fredoverflow
  • 256,549
  • 94
  • 388
  • 662