02:29

How to avoid deadlock in JAVA

How to avoid deadlock in Java is one of the question which is flavor of the season for multithreading , asked more at a senior level and with lots of follow up questions , though question looks very basic but most of developer get stuck once you start going deep.

questions starts with "What is deadlock ?"
answer is simple , when two or more threads waiting for each other to release lock and get stuck for infinite time , situation is called deadlock . it will only happen in case of multitasking.


How do you detect deadlock in Java [.....]

01:23

How Post Increment operator actually works in JAVA

Ohk,So let me give you one code snippet guess the output if you are correct then you don't need to look further because your concept about the topic is clear well enough :) ,But incase if you can't get the right answer then go through this post it really helps you.

public class TestPostIncrement{ public static void main(String args[]){ int j=0; for(int i=0;i<100;i++){ j=j++; } System.out.println(j); } So what is your answer?

The output will be all zeros.... :)

All magic is happened at line j=j++; .

According to JAVA documentation assignments of this form: lhs = rhs++; is similar to doing something like this: temp = rhs; rhs = rhs+1; // increment lhs = [.....]