All Questions

55
votes
1answers
4180 views

Loop doesn't see changed value 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 Syst...
57
votes
5answers
36182 views

Asynchronous Process inside a javascript for loop

I am running an event loop of the following form: var i; var j = 10; for (i = 0; i < j; i++) { asycronouseProcess(callBackFunction() { alert(i); }); } What I would like this to ...
316
votes
18answers
121464 views

Avoid synchronized(this) in Java?

Whenever a question pops up on SO about Java synchronization, some people are very eager to point out that synchronized(this) should be avoided. Instead, they claim, a lock on a private reference is t...
92
votes
9answers
51644 views

C++0x has no semaphores? How to synchronize threads?

Is it true that C++0x will come without semaphores? There are already some questions on Stack Overflow regarding the use of semaphores. I use them (posix semaphores) all the time to let a thread wait ...
57
votes
4answers
24510 views

Synchronization and System.out.println

If multiple threads call System.out.println(String) without synchronization, can the output get interleaved? The API makes no mention of synchronization, so this seems possible, or is interleaved out...
275
votes
9answers
84580 views

How to Sync iPhone Core Data with web server, and then push to other devices?

I have been working on a method to sync core data stored in an iPhone application between multiple devices, such as an iPad or a Mac. There are not many (if any at all) sync frameworks for use with Co...
140
votes
9answers
128168 views

Synchronization vs Lock

java.util.concurrent API provides a class called as Lock, which would basically serialize the control in order to access the critical resource. It gives method such as park() and unpark(). We can d...
340
votes
8answers
192127 views

How does lock work exactly?

I see that for using objects which are not thread safe we wrap the code with a lock like this: private static readonly Object obj = new Object(); lock (obj) { // thread unsafe code } So what h...
200
votes
6answers
95927 views

What is the difference between atomic / volatile / synchronized?

How do atomic / volatile / synchronized work internally? What is the difference between the following code blocks? Code 1 private int counter; public int getNextUniqueIndex() { return counter+...
4
votes
2answers
5642 views

Wait Firebase async retrive data in android

i need to store the result of FireBase getValue method that is async by his own. I can't use something like "onPostExecute()" and, for my purpose, i can't execute all my operation "into onDataChange()...

Previous Next