• Post Reply Bookmark Topic Watch Topic
  • New Topic

synchronizing single element in collections  RSS feed

 
Wai Yip Lau
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing my own hashtable that supports multi-thread. I want to allow simultaneous insertion and deletion on different buckets. Is it difficult to do? I have been thinking to do this using simple intrinsic lock. Do I need to use the new concurrent package?
 
Lucas Lee
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you'd better check java.util or java.util.concurrent package first before you write your own implementation.
You can avoid duplicated work and difficult problems if you can use exsiting code.
 
Henry Wong
author
Sheriff
Posts: 23280
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if the "new concurrent package" is an option... you can use this.

Henry
 
Wai Yip Lau
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
Actually I am doing an assignment about a synchronized hash table, but the requirement does not specify me to lock the whole table or single bucket. It seems I am going to redo the implementation as in the java package. I have found a sample source file of the ConcurrentHashMap and get some ideas about the logic. I am testing the code. Here are some resources to share:

http://www-128.ibm.com/developerworks/java/library/j-jtp08223/
http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html
[ November 28, 2006: Message edited by: Wai Yip Lau ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!