Mar Java Mit Java Blog

What is destructuring 0

What is destructuring

Destructuring allows you to easily extract values from Objects or Arrays and assign to new values or even assign default values to undefined properties Imagine this code : user = { name: ‘dave’, gender:...

What is a Pipeline Operator 0

What is a Pipeline Operator

Pipeline operator is still in draft stage and it might be part of next Js release. It’s a backwards-compatible way of streamlining chained function calls in a readable, functional manner let result = “hello”...

Why do we need threadlocal in Java 0

Why do we need threadlocal in Java

The ThreadLocal class in Java enables you to create variables that can only be read and written by the same thread. Thus, even if two threads are executing the same code, and the code has a...

Using Java client to interact with MongoDB 0

Using Java client to interact with MongoDB

The official MongoDB Java Driver provides both synchronous and asynchronous interaction with MongoDB. Following are the operations supported in MongoDB : Connect How to connect to a mongodb server MongoClient mongoClient = MongoClients.create(“mongodb://host1:27017”); Cluster...

What is CORS and how is it used 0

What is CORS and how is it used

Let’s say we wanted to provide a service at http://orlandotemp.net/temp that responds to AJAX GET requests from the external site example.com with a JSON object containing the current temperature in Orlando, FL. All we need to do to enable this...

How to enable CORS in Tomcat and JBOSS 0

How to enable CORS in Tomcat and JBOSS

For jboss we can use a solution from thetransactioncompany: web.xml: maven: If you use apache Tomcat you can use built-in CorsFilter: web.xml: pom.xml:

What should we avoid in thread dumps 0

What should we avoid in thread dumps

One of the most common trick is knowing what to ignore safely. Let’s have a look at sample thread dump: “Atmosphere-Scheduler-3162” nid=137911 state=TIMED_WAITING [] java.lang.Thread.State: TIMED_WAITING – waiting on <0x2db6a729> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) – locked...

What is an example of Livelock 0

What is an example of Livelock

Here’s a very simple Java example of livelock where a husband and wife are trying to eat soup, but only have one spoon between them. Each spouse is too polite, and will pass the...

What is difference between ORACLE JDK and OPENJDK 0

What is difference between ORACLE JDK and OPENJDK

Oracle’s BCL-licensed JDK historically contained “commercial features” that were not available in OpenJDK builds. As promised, however, over the past year Oracle has contributed these features to the OpenJDK Community, including: Java Flight Recorder, Java...

How does redis cluster work 0

How does redis cluster work

So this is how redis cluster will look like which has 3 masters and 3 slaves.Each master node has a slave node. If master node goes down, slave node will be promoted to the...