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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:23:43+00:00 2026-05-28T04:23:43+00:00

Hello have only a few days with Java and android here. I am a

  • 0

Hello have only a few days with Java and android here. I am a bit confused about exactly how the “implements runnable” actually works example:

public class DrawableSurfaceView extends SurfaceView implements Runnable {

[...]

public void resume(){
    isRunning = true;
    mThread = new Thread(this);
    mThread.start(); //start the animation
    parseParameters(); //<== Here is my problem
}

public void run() {
    while (isRunning == true){
        if (!mHolder.getSurface().isValid()) {
         continue;
        }
        Canvas canvas = mHolder.lockCanvas();
        canvas.drawARGB(255, 0, 0, 0);
        canvas.drawPath(PenPath, PenPaint);
        canvas.drawPath(CursorPath, CursorPaint);
        mHolder.unlockCanvasAndPost(canvas);
    }
}
public void parseParameters() {
  [...]
  [ The rest of my code here  modifying PenPath and CursorPath, etc ]

}

I am embarrassed to ask, but I thought that after mThread.start(); a new thread would be started running a loop in the run method. instead what I get is the run method only executed after my parseParameters() method terminates.
What I wanted to achieve is to have the canvas on a drawing loop thread and externally modify the parameters of the drawing paths to generate my animation.
I am sure this is very elemental, but I have been unable to understand this for a few hours. The docs are not helping.

Any pointer would help a lot. Cheers guys!

  • 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-28T04:23:43+00:00Added an answer on May 28, 2026 at 4:23 am

    It seems that in this situation you would not want to implement any kind of loop yourself. You would want to override the onDraw(Canvas canvas) in your custom view. With this you can force onDraw to be called by calling invalidate() on your view from anywhere. You could accept parameters from an outside source as well.

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

Sidebar

Related Questions

Hello only have a few hours with Java. (from Python) I am trying to
I have few questions about string literals in C++. char *strPtr = "Hello" ;
Hello fellow programmers I have been searching the internet for a few days now
Hello All at StackOverflow, over the last few days I have had some problems
I have been building my own carasol over the past few days. My Jquery
I started to develop android apps a few days ago, but I'm stuck with
Hello I have a ASPxGridView. In it(for the uninformed) is only a DataSource property
Hello how can I delete anything of this string and have only the XBH1dcHoL6Y
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello we have an SQL server application running over a low bandwith connection. We

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.