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

  • SEARCH
  • Home
  • 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 8085793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:14:30+00:00 2026-06-05T18:14:30+00:00

Hello i am having a problem with resuming a thread my code is public

  • 0

Hello i am having a problem with resuming a thread my code is

 public boolean Wait(String Reply){     
        if (Reply.equalsIgnoreCase("Y")){
            try {
                t.resume();
            }
            catch (Exception e){
              System.out.println("\n" + "The exception in resume thread method:::: " + e);                
            }
            System.out.println("\n" + "In the Wait Function of Sender");
            return true;

        }
        JOptionPane.showMessageDialog(j ,
                    "Please Wait While The User Accpets the Trasmission ",
                    "",
                    JOptionPane.INFORMATION_MESSAGE);


       try{
         t = new Thread(this);
         t.sleep(100000);  
        }
       catch (InterruptedException ie){
         System.out.println(ie.getMessage());
       }
    return false;
}

I might explain you how it works as it will help u determine the problem.
First the thread is put to sleep……Then i call this public boolean Wait() function from another function named ReplyYes which passes the value “Y” and i then try to resume the thread but the t.resume() function call, instead of resuming the thread gives me a Java.Lang.Null.PointerException and the thread isn’t resumed resulting in returning a FALSE value. Plus because of this thread i can’t even Stop my Service i have to wait for the thread to timeOut.

Can anyone explain how to make it work correctly!!
Thank you

  • 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-06-05T18:14:32+00:00Added an answer on June 5, 2026 at 6:14 pm

    I think you misunderstand how Thread.sleep works. It is a static method.

    The line t.sleep(100000); puts the current thread to sleep, not the thread t.

    From the documentation:

    Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds

    Emphasis mine.

    You should start the thread and call sleep from that thread. See the following article for two different ways to start a thread:

    • Defining and Starting a Thread

    Furthermore, resume is only for use with suspend and they have both been deprecated. From the documentation:

    Deprecated. This method exists solely for use with suspend(), which has been deprecated because it is deadlock-prone. For more information, see Why Are Thread.stop, Thread.suspend,
    Thread.resume and Runtime.runFinalizersOnExit Deprecated?

    The reason you get a NullPointerException is probably because you try to create the new Thread object after you call t.resume(). So at that point, t still has the value null. Basically, your code needs to be completely rewritten from scratch. I would suggest following the tutorial I linked to above, then once you understand how to create threads move to the next chapters:

    • Pausing Execution with Sleep
    • Interrupts
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I am having some problems with the code below. The try and catch
Hello guys am having a problem with downloading modules. Anytime i try to download
Hello I'm having a problem here. The code looks like this. private void Form3_Load(object
Hello i am having this problem: i am downloading data from xml using linq
Hello I am having a problem with the numbering of figures using Latex, I
Hello I am a new user to Python and I am having problem doing
hello i am having an error : Attempt to access the method failed: System.IO.File.Exists(System.String)
Hello guys Im having a problem in how to clear the previous activity after
Hello i am just Studying 3-tier Application. I am now having a problem with
Hello i am having a problem in setting the image in relative layout.The problem

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.