raja singh kumar

Ranch Hand
+ Follow
since Aug 26, 2016
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by raja singh kumar

Not sure if the question belongs to this category but I had a question. Please feel free to move the question to the appropriate category.

Is facebook a web application or an enterprise application?
1 week ago
I am following the example given in  the below link


In this there is one to many relation  between Employee and Account. Employee is the one side of the relationship. Account is the many side of the relationship.

Here the extra association column needs to be generated on the Account side but the JoinColumn annotation is used in the Employee entity.

Is the joincolumn annotation not supposed to be used on the owning side(side responsible for association column update) which is the Account entity since it is the many side of the relationship and defaulting to the owning side(since it is the many side of the relationship)?


I understand that cyclic barrier can be reused. In that case a cyclic barrier can be used over multiple phases. Then how is it different from a phaser? Appreciate a detailed explaination.
I came to know that there are 4 ways to generate a primary key automatically in Hibernate. They are as shown below.

My question is for which database which strategy needs to be used? Also is the working of each of these different internal implementations or there is something which needs to be done different externally?

I would appreciate a detailed answer preferably with an example and explanation.

I have an arraylist in which I add 3 items. I pass the list to a method which adds 2 more items. After that when  I try to print the list in the calling method it contains the updated list.

Does this example not prove that Java is not always pass by value?

3 months ago
I dont get it. Is the lock acquired on object of SynchronizedCounter when accessing synchronized method of  SynchronizedCounter?

Stephan van Hulst wrote:There are two threads: the main thread and the thread you started.

The main thread calls shutdown() which writes to the running variable, while your new thread reads it.

Thank you
We know that locks are associated with objects. In the below example program there are 3 synchronized methods. Lock is acquired for which object? Also when a thread is executing the increment method can a second thread invoke the decrement method?

We know that:
The Java volatile keyword guarantees visibility of changes to variables across threads.

In the below example code there is only 1 thread being used. How is this an example of volatile keyword when there is only a single thread being used?
When I create a new String("abc") how many objects are created and where are they created? If there are 2 objects created 1 in the heap memory and 1 in String pool then what is the use of intern?
4 months ago
Hi All,

Can someone please tell me a real life example of when we would need to go for singleton design pattern?

Hi All,

From the official documentation of Java

"If t is a Thread object whose thread is currently executing,
causes the current thread to pause execution until t's thread terminates."

My question is it possible to get into a deadlock situation if t is the currently executing thread and we call a join on thread t? Please clarify with an example, if required.
Hi All,

I have the below program which prints different states the threads are in but I do not see the state as "BLOCKED" at any point of time. Can I do something in the below code to get it to that state?


State of thread1 after creating it - NEW
State of thread1 after calling .start() method on it - RUNNABLE
State of thread2 after creating it - NEW
State of thread2 after calling .start() method on it - RUNNABLE
State of thread2 after calling .sleep() method on it - TIMED_WAITING
State of thread1 while it called join() method on thread2 -WAITING
State of thread2 when it has finished it's execution - TERMINATED
The code prints 1000000000 but whats the point. I did not get it.

I was reading about multithreading and I came across the term "blocked state" or "blocked for I/O". Can someone tell me what is a "blocked " state and "blocked for I/O" state mean and explain with an example? Also, when does a thread enter the blocked state?