java.util.concurrent.locks in java

java.util.concurrent.locks

when and how to use above package. Any simple examples in using about thread package. Please advise
LVL 7
gudii9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dpearsonCommented:
You only need to use the locks package if you're writing your own, low level threading code.

That should be extremely uncommon.

You should instead spend time looking into and learning how to use the higher level classes in the concurrent package:
http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/package-summary.html

in particular probably:
ConcurrentHashMap
PriorityBlockingQueue
CopyOnWriteArrayList

If you can master those, you likely won't need to write low level locking code.  (These library classes use that package themselves).

Doug
1
gudii9Author Commented:
ConcurrentHashMap
PriorityBlockingQueue
CopyOnWriteArrayList

any good sample simple examples using above 3 interfaces. please advise
0
dpearsonCommented:
Each of those is a pretty big concept to get your head around.

I'd suggest focusing on ConcurrentHashMap first - it's probably the most commonly used of all the concurrency classes.

Some tutorials here:
http://javarevisited.blogspot.com/2013/02/concurrenthashmap-in-java-example-tutorial-working.html
http://www.javamex.com/tutorials/synchronization_concurrency_8_hashmap2.shtml

Doug
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.