-1

Now I want to make HashMap synchronized .Is there any way I can do the same without using Synchronized keyword ConcurrentHashMap?or ? That is I dont want to put all the methods inside a Synchronized block .

dilshad
  • 686
  • 1
  • 9
  • 27

1 Answers1

2

Now I want to make ArrayList and HashMap synchronized .Is there any way I can do the same without using Synchronized keyword ?

Sure:

  1. Use a ConcurrentHashMap and any of the several List implementations in java.util.concurrent.

  2. Use Collections.synchronizedMap and Collections.synchronizedList.

T.J. Crowder
  • 959,406
  • 173
  • 1,780
  • 1,769