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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:39:49+00:00 2026-06-18T08:39:49+00:00

I was trying to make an adjustable sequence of time by using scheduleatfixedrate. However,

  • 0

I was trying to make an adjustable sequence of time by using scheduleatfixedrate.
However, when I made this block of code I didn’t know that one can’t change the period after it has been executed unless the timer is purged.

This is my attempt at a sequenced series of events:

@Override
protected void onStart()
{


    super.onStart();

    Timer timer = new Timer();
    GregorianCalendar gCal = (GregorianCalendar) GregorianCalendar.getInstance();




    final Runnable countDivision = new Runnable()
    {
        public void run()
        {

            /**
             * Starts the sequence and wraps around when reached the last position
             */

            if(playSequenceButton.isChecked())
            {
                setEnabled(true);
                int length = sequencer.getLength();
                int i = sequencer.getPosition();
                DIODE[i].setChecked(true);
                if(i > 0)
                    DIODE[i-1].setChecked(false);
                if (i < 1)
                    DIODE[length].setChecked(false);



            }
            /**
             * Stops and resets the sequence
             */
            else
            {
                for (int i = 0; i < sequencer.getLength(); i++)
                    DIODE[i].setChecked(false);

                sequencer.setPosition(START_POSITION);
                setEnabled(false);

            }
        }
    };

    int millis = 999 - gCal.get(GregorianCalendar.MILLISECOND);
    int inputBPM = TEMPO;
    long qtrN=Math.round(((60000/inputBPM))*100000)/100000;

    long sixteenN = (qtrN/4);
    sixteenN=Math.round(sixteenN*100000)/100000;


    timer.scheduleAtFixedRate(new TimerTask()
    {

        @Override
        public void run()
        {
            //              setEnabled(true);
            runOnUiThread(countDivision);               

        }

    }, 0, sixteenN);



}

What method would you recommend for setting a period time that can be dynamically altered?
The sixteenN variable needs to be able to change while the runnable countDivision is running.
Maybe a timertask isn’t the right tool?

Regards
/M

  • 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-18T08:39:51+00:00Added an answer on June 18, 2026 at 8:39 am

    Just cancel and reschedule the TimerTask!

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

Sidebar

Related Questions

Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
Trying to make a Grid Like this using java and I'm assuming a 2d
I'm trying make this code which is from a Dictionary of Arrays (CODE) from
I am trying make an OptionsMenu , this is my code: @Override public boolean
I'm trying make an entity with doctrine that has three associations with other entities
Trying to make a simple number clicker control for BlackBerry 6/7, like this: At
im trying make one replace in string from a array but this dont work
Hello I am trying make a browser cache experiment. like this <head> <script type=text/javascript
Trying to make simple jQuery function to create a scrollToTop button that fades in
Trying to make my project using storyboard. I changed my info.plist and added entry

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.