Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

weakhashmap

Is there java.util.concurrent equivalent for WeakHashMap?

April 13, 2023 by Tarik

Guava’s CacheBuilder class allows you to do this easily. CacheBuilder.newBuilder().weakKeys().build() Note that this changes key equality semantics to be == instead of .equals() which will not matter in your case of using Class instances but is a potential pitfall.

Categories java Tags collections, guava, java, java.util.concurrent, weakhashmap Leave a comment

What is a WeakHashMap and when to use it? [duplicate]

November 18, 2022 by Tarik

Elements in a weak hashmap can be reclaimed by the garbage collector if there are no other strong references to the key object, this makes them useful for caches/lookup storage. Weak reference are not restricted to these hash tables, you can use WeakReference for single objects. They are useful to save resource, you can keep … Read more

Categories java Tags collections, java, weakhashmap Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa