Skip to main content

Posts

Showing posts from January 28, 2018

Java Multi threaded programming basics with Reentrant lock

Java Multi threaded programming basics with Reentrant locks As we have seen in earlier post that implicit locking mechanism achieved using synchronized keyword slows down the application performance. Hence java concurrency api gives explicit locking mechanism to achieve mutual exclusion among shared object. How using explicit locks are better than implicit lock? Explicit lock acquires lock per Thread basis and not per method invoke basis. It is inverse in the case of implicit lock.   If a method is synchronized then every invocation of that method involves acquiring and releasing of lock. This process really slows down the application performance.  Hence it is always good idea to prefer reentrent lock or explicit lock to implicit lock. ReentrantLock is a class available in java.util.concurrency package lock() and unlock() methods are used used to acquire and release the lock. Condition class is used in place of Object class wait(), notifyAll() and notify(). ...

Java desktop GUI.

Graphical user interface in short GUI makes computer users easy to understand and use the application software comfortably. Almost all modern programming languages allows application developers to develop GUIs. Java has AWT/Swing as default API as part of Java Foundation classes in short JFC which are shipped with JDK. Hence these toolkits can be used directly in our applications with out adding external libraries like jars to our application's class path. But there are some other toolkits which found useful and industry endorsed in developing GUI.      SWT       JFaces [Framework for SWT]      Java FX      Swing      AWT AWT: Abstract window toolkit is available since java first version. AWT uses native operating system resources like Fonts, colors and components like table, tree, dialogues, windows etc. Few notable points about AWT: AWT is heavy weight. It uses OS resources There are l...