Posts

Asynchronous Data Handling in AngularJs

Asynchronous is great in terms of performance, resource utilization and system throughput.   Handling control flow is really painful. In Jquery and AngularJs we have promises to handle asynchronous requests. A promise represents the eventual result of an operation. You can use a promise to specify what to do when an operation eventually succeeds or fails. Promises in AngularJS are provided by the built-in $q service. How it looks in Client-side:              $http is one of the service that returns promise which contains the response. var promise = $http . get ( "/api/my/name" );   promise . success ( function ( name ) {      console . log ( "Your name is: " + name ); }); promise . error ( function ( response , status ) {      console . log ( "The request failed with response " + response + " and status code " + status ); }); How it looks in Server-side: Promises in AngularJS are provided by th

All about Java Multi Threading

Terms used in Multi-threading Daemon threads The daemon threads are basically the low priority threads that provides the background support to the user threads. Thread class setDaemon(true) can be used to create daemon thread in java. We need to call this method before calling start() method else it will throw IllegalThreadStateException. Analyze a deadlock To analyze a deadlock, we need to look at the java thread dump of the application, we need to look out for the threads with state as BLOCKED and then the resources it’s waiting to lock, every resource has a unique ID using which we can find which thread is already holding the lock on the object. Avoid Nested Locks, Lock Only What is Required and Avoid waiting indefinitely are common ways to avoid deadlock situation, read this post to learn how to  analyze deadlock in java  with sample program. Ways to achieve Synchronization There are several ways to achieve thread safety in java – synchronization, atomic con

Dependency Injection & IoC

Image
Inversion of Control Inversion of Control is a design pattern in which the flow of control of a system is inverted in comparison to procedural/traditional programming. It can delegate the control flow by callback delegates, observer pattern, events, DI (Dependency injection) and lot of other ways rather than the internal program controlling the flow. It could be used for decoupling components and layers in the system.  The pattern is implemented through injecting dependencies into a component when it is constructed. Dependency Injection Dependency injection is a style of object configuration in which an objects fields and collaborators are set by an external entity. The traditional method utilizes 'Dependency Lookup' to resolve its dependencies. It is a process injecting (or initializing, resolving and pushing) dependencies to an object, rather than letting it to resolve by itself. In Spring, the IoC is implemented by Spring IoC Container. Advantage

First Post!!!

Hi everyone!!! This is Balaji, working as a Java developer in a Service based MNC. This blog is to provide convincing, to the point, easy to remember explanations to the popular Java concepts. It will be one stop shop for each concept with definitions, code snippets and Quotes. I'll update posts whenever I face issues, if you want explanation on any specific concept please utilize the Contact Me page. If you have any differed suggestions or remarks or content I can add, Please drop a comment. Also, if you are willing to add your content, I'm open to delegate author rights.