Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6191705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:48:48+00:00 2026-05-24T02:48:48+00:00

I am implementing an application in which I play two sounds ( touchandshow followed

  • 0

I am implementing an application in which I play two sounds (“touchandshow” followed by “tiger“). This is done in my looper method. I call it a first time, then call wait(), then call looper again.

The problem is that I get an exception in the LogCat from the wait() call.

Here is my code:

        mPlayer = MediaPlayer.create(this, R.raw.touchandshow);
    mPlayer2 = MediaPlayer.create(this, R.raw.tiger);

    try {

        looper();
        wait(2000);

        looper();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

public void looper() {
    CountDownTimer aCounter;
    aCounter = new CountDownTimer(2000, 1000) {
        public void onTick(long millisUntilFinished) {
            mPlayer.start();
        }

        public void onFinish() {
            mPlayer2.start();
        }
    };
    aCounter.start();

}  

And the LogCat:

    07-29 10:20:09.412: ERROR/AndroidRuntime(1188): FATAL EXCEPTION: main
07-29 10:20:09.412: ERROR/AndroidRuntime(1188): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.AudioTesting/com.AudioTesting.AudioTesting}: java.lang.IllegalMonitorStateException: object not locked by thread before wait()
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at android.os.Looper.loop(Looper.java:123)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at android.app.ActivityThread.main(ActivityThread.java:4627)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at java.lang.reflect.Method.invokeNative(Native Method)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at java.lang.reflect.Method.invoke(Method.java:521)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at dalvik.system.NativeStart.main(Native Method)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188): Caused by: java.lang.IllegalMonitorStateException: object not locked by thread before wait()
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at java.lang.Object.wait(Native Method)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at java.lang.Object.wait(Object.java:326)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at com.AudioTesting.AudioTesting.onCreate(AudioTesting.java:25)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-29 10:20:09.412: ERROR/AndroidRuntime(1188):     ... 11 more

Can anyone tell me what I’m doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:48:48+00:00Added an answer on May 24, 2026 at 2:48 am
    java.lang.IllegalMonitorStateException: object not locked by thread before wait()
    

    Your problem is this message. You can’t call wait on an object you haven’t locked first. wait is meant for synchronization, not as a generic “sleep” facility.

    If you just want to pause your thread, use:

    Thread.sleep(2000);
    

    inside your try block instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing the application which consumes webservice (first authentication and then calling different
I'm implementing an application which want to draw lines in the panel. But the
I'm implementing a Rails application in which users will be able to store snippets
I have an application on which I am implementing localization. I now need to
I am implementing a web application which is powered on the backend via a
I am implementing one iphone application in which i want to find direction of
I am implementing a small demo application which encrypts using AES CTR with OpenSSL
I am currently implementing S3 integration into my Rais application which uses Paperclip. Currently,
I have an application which consists of two activities/screens and a java class from
I am implementing game application.In which i have set UIView on camara overly.When i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.