Question: Why is it that two synchronized blocks can't be executed simultaneously by two different threads in Java.

**EDIT**

```
public class JavaApplication4 {

    public static void main(String[] args) {
        new JavaApplication4();
    }

    public JavaApplication4() {
        Thread t1 = new Thread() {

            @Override
            public void run() {
                if (Thread.currentThread().getName().equals("Thread-1")) {
                    test(Thread.currentThread().getName());
                } else {
                    test1(Thread.currentThread().getName());
                }
            }
        };
        Thread t2 = new Thread(t1);
        t2.start();
        t1.start();

    }

    public synchronized void test(String msg) {
        for (int i = 0; i < 10; i++) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
            }
            System.out.println(msg);
        }
    }

    public synchronized void test1(String msg) {
        for (int i = 0; i < 10; i++) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
            }
            System.out.println(msg + " from test1");
        }
    }
}

```

Answer: 
Your statement is false. Any number of synchronized blocks can execute in parallel as long as they don't contend for the same lock.

But if your question is about blocks contending for the same lock, then it is wrong to ask "why is it so" because that is the purpose of the whole concept. Programmers **need** a mutual exclusion mechanism and they get it from Java through `synchronized`.

Finally, you may be asking "Why would we ever need to mutually exclude code segments from executing in parallel". The answer to that would be that there are many data structures that only make sense when they are organized in a certain way and when a thread updates the structure, it necessarily does it part by part, so the structure is in a "broken" state while it's doing the update. If another thread were to come along at that point and try to read the structure, or even worse, update it on its own, the whole thing would fall apart.

EDIT
====

I saw your example and your comments and now it's obvious what is troubling you: the semantics of the `synchronized` modifier of a method. That means that the method will contend for a lock on `this`'s monitor. All `synchronized` methods of the same object will contend for the same lock.
This is not absolutely true. If you are dealing with locks on different objects then multiple threads can execute those blocks.

```
   synchronized(obj1){
       //your code here
   }

   synchronized(obj2){
       //your code here
   }

```

In above case one thread can execute first and second can execute second block , the point is here threads are working with different locks.

Your statement is correct if threads are dealing with same `lock`.Every object is associated with only one lock in java if one thread has acquired the lock and executing then other thread has to wait until first thread release that `lock`.Lock can be acquired by `synchronized` block or method.