Tips to prevent deadlocks in java

Some quick tips out of my head

  • don’t use multiple threads (like Swing does, for example, by mandating that everything is done in the EDT)
  • don’t hold several locks at once. If you do, always acquire the locks in the same order
  • don’t execute foreign code while holding a lock
  • use interruptible locks

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)