Free resources from threads

In my application (in my work) we support a socket pool for communication processing. There are several threads (a large number) that take an active connection from the pool, use it, and close it. But the trick is that somewhere between the garbage collector links are collected that are not used.

Now, after calling the garbage collector, I want:

  • suspend all threads participating in the message (note that my threads run together with GC -> I mean, scheduling allows)
  • release socket connections from the stream (for example, socket connection links), the status of which can be somewhere in the middle or if it is practically impossible:
  • How to delay a GC call after all threads using resources have completed. further in this case, it may be necessary to determine whether the respective threads have completed their work.
+3
source share
1 answer

If you care about when the GC works, then your application design is broken.

Correct your design.


Note. Although there are specifications on how the garbage collector should work, it is not necessary that the JVM implementations have a garbage collector!

+2
source

All Articles