Troubleshooting Java
http://www.oracle.com/technetwork/java/javase/hangloop-140257.html
http://www.javaworld.com/article/2078848/java-concurrency/java-101-the-next-generation-java-concurrency-without-the-pain-part-2.html?page=3
Producer - Consumer
3 possible implementations
1. wait / notify
2. Semaphores
3. CAS - Lock free - Using Atomic variables
Again
- wait() / notify() - synchronisation / Lock.lock() & Lock.unlock() - locking
- Using Memory Barriers - volatile to publish state (Can only support 1 producer & 1 consumer)
- CAS - Lock Free - Using Atomic variables
http://en.wikipedia.org/wiki/Producer%E2%80%93consumer_problem
http://concurrencykit.org/presentations/lockfree_introduction/#/
Lock-Free Algorithms
Wait-Free Algorithms
Concurrency Control
Optomistic Concurrency Control
While running, transactions use data resources without acquiring locks on those resources. Before committing, each transaction verifies that no other transaction has modified the data it has read. If the check reveals conflicting modifications, the committing transaction rolls back and can be restarted.
if notify() happens between condition-check & call to wait().
http://docs.oracle.com/cd/E19455-01/806-5257/sync-30/index.html
Why we need to check the condition in a Loop - Spurious Wakeup -
https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/Condition.html
All about MultiThreading - http://tutorials.jenkov.com/java-concurrency/thread-signaling.html
Volatile
Volatile fields are instance or class (static) variables and are stored in the heap. I think if its static field it can be stored on the Method Area ( which can itself be in the Heap Area (Permgen ?) )
No comments:
Post a Comment