double-checked-locking Questions

5

Solved

Consider the "double-check idiom for lazy initialization of instance fields": // Item 71 in Effective Java copied from this interview with Bloch. private volatile FieldType field; FieldType getFie...
Otes asked 20/11, 2008 at 22:20

4

Solved

In the examples mentioned for Out-of-order writes for double-checked locking scenarios (ref: IBM article & Wikipedia Article) I could not understand the simple reason of why Thread1 would come...

2

Solved

The fallowing clause is taken from jetbrains.net After reading this and some other articles on the web, I still don't understand how is it possible to return null, after the first thread go in to t...
Haleakala asked 23/4, 2012 at 13:0

2

Solved

void undefined_behaviour_with_double_checked_locking() { if(!resource_ptr) #1 { std::lock_guard<std::mutex> lk(resource_mutex); #2 if(!resource_ptr) #3 { resource_ptr.reset(new some_res...

3

Solved

I have a queston regarding double-checked locking. Consider this example: public class Singleton { private static volatile Singleton instance = null; public static Singleton getInstance() { ...
Disorganize asked 7/12, 2011 at 9:33

2

Solved

I have the following code which could be called via multiple web-requests at the same second. As such, I don't want the second+ request hitting the database, but waiting until the first one does. ...
Apices asked 24/8, 2011 at 1:9

5

Solved

I keep on running across code that uses double-checked locking, and I'm still confused as to why it's used at all. I initially didn't know that double-checked locking is broken, and when I learned...

5

Solved

Does this code solve the double checked locking issue in Java? public class DBAccessService() { private static DBAccessService INSTANCE; private DBAccessService() {} public static DBAccessSe...
Apple asked 12/5, 2011 at 9:45

4

Solved

I've got a web application where people ask for resources. This resources are cached using a synchronized hash map for efficiency. The problem here is when two different requests come for the same ...

2

Solved

Possible Duplicate: Double-checked locking in .net EDIT: lots of edits to clarify this question is not about singleton I find myself writing code like this: if(resourceOnDiskNeedsU...
Apsis asked 18/2, 2011 at 0:43

1

Solved

I'm new to PHP, so to get started I've decided to implement a singleton. While I am able to recreate the singleton pattern in php, but I am not sure how to implement double-checked locking. Is th...

2

Solved

In C#, the following code (from this page) can be used to lazily instantiate a singleton class in a thread safe way: class Foo { private volatile Helper helper = null; public Helper getHelper()...

7

Solved

Why is the pattern considered broken? It looks fine to me? Any ideas? public static Singleton getInst() { if (instace == null) createInst(); return instace; } private static synchronized create...
Insurrectionary asked 1/9, 2010 at 9:48

5

Solved

Java 5 and above only. Assume a multiprocessor shared-memory computer (you're probably using one right now). Here is a code for lazy initialization of a singleton: public final class MySingleton ...
Transnational asked 30/8, 2010 at 14:58

5

Solved

Recently I've seen some C# projects that use a double-checked-lock pattern on a Dictionary. Something like this: private static readonly object _lock = new object(); private static volatile IDicti...
Labanna asked 12/4, 2010 at 18:15

3

I was reading the article Double-checked locking and the Singleton pattern, on how double checked locking is broken, and some related questions here on Stack Overflow. I have used this patte...
Warsle asked 20/3, 2010 at 5:40

10

Solved

I was reading this article about "Double-Checked locking" and out of the main topic of the article I was wondering why at some point of the article the author uses the next Idiom: Listing 7. At...
Latashialatch asked 1/10, 2008 at 11:34

4

Solved

Checkstyle reports this code as "The double-checked locking idiom is broken", but I don't think that my code actually is affected by the problems with double-checked locking. The code is supposed ...
Wrand asked 1/12, 2008 at 6:50

© 2022 - 2024 — McMap. All rights reserved.