Skip to main content

Posts

Completable Future - Java 8 Async

We know that java 5 had Future interface for representing the result of asynchronous executions in a multithreaded environment. Java 8 introduces CompletableFuture which is very advanced and has overcome some issues that were there in Future - Java 5. 1. It didn't have exception handling capability - lets say there was exception thrown by the thread executing asynchronously - then that exception is lost, it will not be propagated to main thread. 2. Call back function capability was not there If you want a function to be called when the async thread completes and Future result was available, it was not possible. Only way was to call get() method and block for it's completion. 3. Chaining multiple callbacks or Futures was not possible If you have several asynchronous calculations to be chained together it was not possible. Again only was to use get() method and blocking on it. Completable Future Lets see how to create a Completable Future CompletableFuture<String> future=n
Recent posts

Neo4j - Basic Usecase Tutorial

  GraphDB GraphDB is a database concept where they save the data that we have in graph topology. That means they store data as nodes and edges which connect each node. Node can also have properties and edges can also have properties. This concept eases in finding relationship between nodes using edges, also traversing from node to node is easy. Using this concept there are many databases. In this example we will see  Neo4j . There are mainly three building blocks of a neo4j - Node, Relationship, Properties. Let us Consider a simple example to better understand it like social media. Here there will be entity Person he can have many friends, each person lives in a City, lets just consider this scenarios. RDBMS.  If we want to design this in RDBMS way - we can have three tables Person - with name(String), age(Int), id, city_id City - with name(String), id Friends - with id, id, fromYears(int) if one person is friend of another we store that in Friends table with id of both persons and whe