Skip to main content
added 85 characters in body
Source Link
lauthu
  • 141
  • 4

Advice 1

This implementation is not thread safe. For example, if two threads invoked getElement(key1) simultaneously, they may enterruns to ifconcurrentLinkedQueue.add(key) block at same times(they both performed delete and get, but delete will fail the second time or just do nothing), and end up with addingthen two same entry to concurrentLinkedQueue keys will be added.

Advice 2

Maybe capacity is more suitable than maxSize.

Advice 3

LinkedHashMap is often used as LRU cache.

Advice 1

This implementation is not thread safe. For example, if two threads invoked getElement(key1) simultaneously, they may enter if block at same time, and end up with adding two same entry to concurrentLinkedQueue .

Advice 2

Maybe capacity is more suitable than maxSize.

Advice 3

LinkedHashMap is often used as LRU cache.

Advice 1

This implementation is not thread safe. For example, if two threads invoked getElement(key1) simultaneously, they may runs to concurrentLinkedQueue.add(key) at same times(they both performed delete and get, but delete will fail the second time or just do nothing), then two same keys will be added.

Advice 2

Maybe capacity is more suitable than maxSize.

Advice 3

LinkedHashMap is often used as LRU cache.

Source Link
lauthu
  • 141
  • 4

Advice 1

This implementation is not thread safe. For example, if two threads invoked getElement(key1) simultaneously, they may enter if block at same time, and end up with adding two same entry to concurrentLinkedQueue .

Advice 2

Maybe capacity is more suitable than maxSize.

Advice 3

LinkedHashMap is often used as LRU cache.