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

Why does notifyAll() raise IllegalMonitorStateException when synchronized on Integer?

Why does this test program result in a java.lang.IllegalMonitorStateException? public class test { static Integer foo = new Integer(1); public static void main(String[] args) { synchronized(foo) { foo++; …
jjvainio
  • 571
  • 1
  • 5
  • 7
41
votes
6 answers

Why is it not a good practice to synchronize on Boolean?

My architect always says that Never synchronize on Boolean I am not able to understand the reason why and would really appreciate if someone could explain with an example as to why it is not a good practice. Reference Sample Code private Boolean…
Rachel
  • 100,387
  • 116
  • 269
  • 365
40
votes
2 answers

Lock (Monitor) internal implementation in .NET

For mastering of some technology you have to know how it's made at one abstraction level lower. In case of multithreading programming, it will be good to know about synchronization primitives. Here is the question, how implemented Lock (Monitor) in…
alexber
  • 647
  • 1
  • 5
  • 9
40
votes
1 answer

PHP - sleep() in milliseconds

Does PHP provide a function to sleep in milliseconds? Right now, I'm doing something similar to this, as a workaround. $ms = 10000; $seconds = round($ms / 1000, 2); sleep($seconds); I'd like to know whether there is a more generic function that is…
Navaneeth Mohan
  • 557
  • 1
  • 5
  • 9
39
votes
5 answers

Is it possible to use mutex in multiprocessing case on Linux/UNIX ?

This is an interview question. Is it possible to use mutex in multiprocessing case on Linux/UNIX ? My idea: No, different processes have separate memory space. mutex is only used for multithreading. semaphore is used for multiprocessing to do…
user1002288
  • 4,860
  • 10
  • 50
  • 78
39
votes
6 answers

difference between synchronizing a static method and a non static method

What is the difference between synchronizing a static method and a non static method in java?Can anybody please explain with an example. Also is there any difference in synchronizing a method and synchronizing a block of code?
Ammu
  • 5,067
  • 9
  • 34
  • 34
39
votes
4 answers

How to resynchronize with chrony?

I am looking for an equivalent of 'ntpdate IPaddress' command in the chrony suite to force chronyd to synchronize time right now.
Nfernandez
  • 646
  • 1
  • 5
  • 16
39
votes
5 answers

How to fix Perforce error "Can't clobber writable file" or Perforce Error Message - Can't Clobber Writable File

Error: Can't clobber writable file : //file name// Solution: When you try to sync a file, perforce expects your files in workspace will have read-only permissions. If a file is not checked out (by p4 edit) but has write permission then it will…
Shubham Verma
  • 997
  • 1
  • 10
  • 13
39
votes
4 answers

Is it reasonable to synchronize on a local variable?

From the Java memory model, we know that every thread has its own thread stack, and that local variables are placed in each thread's own thread stack. And that other threads can't access these local variables. So in which case should we synchronize…
NingLee
  • 1,477
  • 2
  • 17
  • 26
39
votes
9 answers

How to correctly use sync.Cond?

I'm having trouble figuring out how to correctly use sync.Cond. From what I can tell, a race condition exists between locking the Locker and invoking the condition's Wait method. This example adds an artificial delay between the two lines in the…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
39
votes
13 answers

Android Studio update 0.5.3 - platform 'android-19' not found

Yesterday I opened Android Studio and it asked me to be updated. I now have v0.5.3, SDK 19 fully installed and gradle 0.9.+. I think this information is correct but I'm not fully aware how the gradle strategy works. The problem is that my gradle…
Supercelo
  • 399
  • 1
  • 3
  • 9
39
votes
5 answers

using ThreadStatic variables with async/await

With the new async/await keywords in C#, there are now impacts to the way (and when) you use ThreadStatic data, because the callback delegate is executed on a different thread to one the async operation started on. For instance, the following simple…
theburningmonk
  • 15,701
  • 14
  • 61
  • 104
38
votes
10 answers

Is synchronization within an HttpSession feasible?

UPDATE: Solution right after question. Question: Usually, synchronization is serializing parallel requests within a JVM, e.g. private static final Object LOCK = new Object(); public void doSomething() { ... synchronized(LOCK) { ... } …
basZero
  • 4,129
  • 9
  • 51
  • 89
38
votes
4 answers

BrowserSync extremely slow

I would love to use BrowserSync for development. However, page loading (not only reloading after changes) is extremely slow. I use the proxy mode. Browsing the page without BrowserSync is fast as it should be. One reason may be the following error…
Rico Leuthold
  • 1,975
  • 5
  • 34
  • 49
38
votes
1 answer

Keeping two YouTube videos in sync with each other

I've got two identical YouTube videos embedded on the same page. I'd like them to both be in sync, here are my requirements / notes: Both videos must start at the same time When a video is played / paused by the user the other video does the…
Ben Everard
  • 13,652
  • 14
  • 67
  • 96