lock « Thread Safe « Java Thread Q&A

Home
Java Thread Q&A
1.concurrency
2.Development
3.Exception
4.Notify
5.Operation
6.Socket
7.State
8.synchronize
9.Thread Safe
10.ThreadPool
Java Thread Q&A » Thread Safe » lock 

1. Resetting a field lazy-loaded with the double-check idiom    stackoverflow.com

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 getField() {
    ...

2. Is this (Lock-Free) Queue Implementation Thread-Safe?    stackoverflow.com

I am trying to create a lock-free queue implementation in Java, mainly for personal learning. The queue should be a general one, allowing any number of readers and/or writers concurrently. Would you ...

3. Lock Acquisition Order    stackoverflow.com

With the following code, if a thread calls LoggingWidget.doSomething(), what is the order of lock acquisition that the thread has to go through? (i.e. does it get the Lock on LoggingWidget first, ...

4. Java: thread-safe RandomAccessFile    stackoverflow.com

After some serious googleing I found out that the RandomAccessFile-class is not thread-safe. Now I could use one semaphore to lock all reads and writes but I don't think that performs ...

5. Can Semaphore use the double check locking idiom safely?    stackoverflow.com

Is the following Thead Safe in java?

public class TestDCL{
    private static final Semaphore lock = new Semaphore(1);
    private Object instance;

    public Object ...

6. Best Java thread-safe locking mechanism for collections?    stackoverflow.com

What would be the least-slow thread-safe mechanism for controlling multiple accesses to a collection in Java? I am adding objects to the top of a collection and i am very unsure what ...

7. Locking issue : needs some brainstorming suggestions    stackoverflow.com

I have server service which releases the table database if a certain criterian is satisfied. It looks like this

public static void autoUnloadDbTable(final Configuration conf) {
   final String mKey = ...

8. Is it possible to aquire a lock in one method and release it from a different method?    stackoverflow.com

I basically I am using a frame work that calls a bunch of functions from two different threads. I would like one entire thread to complete before the next thread ...

9. Does this code solve the double checked locking issue in Java?    stackoverflow.com

Does this code solve the double checked locking issue in Java?

public class DBAccessService() {
    private static DBAccessService INSTANCE;  

    private DBAccessService() {}

   ...

10. Threads - Why a Lock has to be followed by try and finally    stackoverflow.com

A Lock is always followed by a try/finally block, why?

ReentrantReadWriteLock readWriteLockBitmap = new ReentrantReadWriteLock();
Lock read = readWriteLockBitmap.readLock();
Lock write = readWriteLockBitmap.writeLock();
int shared = 0;

public void function1(){
    read.lock();
   ...

11. 'double checked locking' in singleton - not thread safe    coderanch.com

JVM is supposed to execute code sequentially until it's specified NOT to do so. Actually the JVM is allowed a certain amount of freedom to mess about with that while optimizing. And it can keep data in temporary memory (I imagine registers in hardware) a while before it puts it back in the real variable. Here's a sane summary ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.