Android Java Notify does not trigger wait
<p>I'm trying to understand this concurrent programming with threads and I don't seem to get this wait() and notify()</p>

<p>I suspect that it has something to do with one of my thread waiting forever and the notify is already called. But I don't know how to solve this. I read through others posts on stackoverflow, but could not understand it well. </p>

<p>Here is my code and it would be helpful if someone could pinpoint me to the right direction.</p>

<pre><code>package com.example.thread_android;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Log.d("Stage", "onCreate");

    Runnable AthreadJob = new ARunnable();
    Runnable BthreadJob = new BRunnable();
    Thread myThreadOne = new Thread(AthreadJob);
    Thread myThreadTwo = new Thread(BthreadJob);
    myThreadOne.start();
    myThreadTwo.start();

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}
}

class ARunnable implements Runnable{
@Override
public void run(){
    Log.d("Runnable", "A Inside Run - WAIT");
    try{
        synchronized(this){wait();}
    } catch (InterruptedException e) {}
    //Log.d("Runnable", "A Inside Run - CONTINUE");
}
}

class BRunnable implements Runnable{
@Override
public void run(){
    Log.d("Runnable", "B Inside Run");
    synchronized (this) {notify();}
}
}
</code></pre>
