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 6252689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:51:00+00:00 2026-05-24T13:51:00+00:00

I have a strange error when executing a timertask, what cause it? public void

  • 0

I have a strange error when executing a timertask, what cause it?

public void tick(long milliseconds) {
ctimer = new Timer();
ctimer.schedule(new TimerTask() {
public void run() {
    System.out.println("sec"+sequencer.getMicrosecondPosition()/1000000);           }
}, 0, milliseconds);
}

Error message from command prompt:

Exception in thread "Timer-0" java.lang.NullPointerException
        at MidiTest$1.run(miditest.java:244)
        at java.util.TimerThread.mainLoop(Timer.java:555)
        at java.util.TimerThread.run(Timer.java:505)
  • 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-24T13:51:02+00:00Added an answer on May 24, 2026 at 1:51 pm

    I would bet that sequencer.getMicrosecondPosition() returns a Long and it’s null. The problem happens because autoboxing/unboxing cannot handle nulls.

    edit

    Autoboxing is when java transforms a primitive type to it’s object wrapper, for example long to Long. You can read more about this feature in these docs.

    There’s no recipe to fix this, as it depends on what you want to do. Probably you can replace the body of run() with

    long position = 0;
    if( sequencer.getMicrosecondPosition() != null ) {
        position = sequencer.getMicrosecondPosition();
    }
    
    System.out.println("sec" + position/1000000);
    

    which will default the position to 0 if getMicrosecondPosition() is null

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

Sidebar

Related Questions

I have a strange error where my jquery ajax request doesn't submit all the
I am getting a strange error using jQuery 1.3.2 and Firefox. I have created
I have an application where every now and then I'm getting a strange error.
it is very strange, because this error doesn't happen all the time... I have
We have a strange problem. I added a couple of new schema's and orchestrations
After executing some new code, my C++ application started to behave strange (incorrect or
i have this strange error : wait_fences: failed to receive reply: 10004003 in this
I have a strange error with a css/javascript hover script on all ie versions.
I have a strange error. I have a page which loads values according to
Very strange error, i have a field on an MVC View: <%: Html.CheckBox(Reportable, ViewData[Reportable])%>

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.