Fork/Join
Java multithreading interview questions (java-success.com)
In Java, memory leak can occur due to
1) Long living objects having reference to short living objects, causing the memory to slowly grow.
For example, singleton classes referring to short lived objects.
This prevents short-lived objects being garbage collected.
2) Improper use of thread-local variables.
The thread-local variables will not be removed by the garbage collector as long as the thread itself is alive.
So, when threads are pooled and kept alive forever, the object might never be removed by the garbage collector.
3) Using mutable static fields to hold data caches, and not explicitly clearing them.
The mutable static fields and collections need to be explicitly cleared.
4) Objects with circular references that are reachable from a GC Root object.
Q14. What is the disadvantage of synchronization?
A14. The disadvantage of synchronization is that it can cause deadlocks
when two threads are
waiting on each other to do something. Also, synchronized code has the overhead of acquiring lock,
and preventing concurrent access, which can adversely affect performance.
GraphQL reduces number of Rest APIs
public class
DeadLock {
Thread 1 locking resource 1 Thread 2 locking resource 2
|