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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:14:04+00:00 2026-05-23T02:14:04+00:00

I have this app (Only one activity) that use some android UI and some

  • 0

I have this app (Only one activity) that use some android UI and some native C++ lib to do OpenGl drawing and calculation.

It seems like the activity creates some “binder thread” on it’s own, and I’m pretty sure it causes some corruption amongs my native calls.

What are the binder threads ?
Can they be removed or merge into one ?

  • 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-23T02:14:05+00:00Added an answer on May 23, 2026 at 2:14 am

    Finally found some good infos on the subject.

    • Binder threads can’t be removed or merge, but you can redirect function calls into the main thread pretty easily by using Handler and Runnable objects.

      Handler handle = new Handler(); //Will be associated with current thread
      handle.post(new Runnable ()
      {
          @Override public void run()
          {
          // Your code to be executed in this thread
          //  you can call native code here to make sure they run under this thread.
          }
      });
      
    • But, you can’t use that inside your Native code. So it’s possible that some of your native code create unexpected fault. For that you can synchronize your code inside JNI to minimize weird behavior. (details)

      env->MonitorEnter(obj);
      // Your code 
      env->MonitorExit(obj);
      
    • You can also, redirect some portion of your code to be executed inside the UI thread (which I don’t recommend if you want performance on the UI)

      myActivity.runOnUiThread(new Runnable ()
      {
          @Override public void run()
          {
          // Your code 
          }
      });
      
    • If you use a GLSurfaceView like I do, you can also redirect code into the GL thread

      myGLSurfaceView.queueEvent(new Runnable()
      {
          @Override public void run() 
          {
              /* do something on the GLSurfaceView thread */
      }});
      

    It’s important to notice that android will always create a separate thread for the UI, so calling native code from your UI code, and from somewhere else could obviously cause unexpected behavior.

    Also, using GLSurfaceView will equally generate its own thread for rendering, so the same kind of interraction with native code is to avoid. But, with those few hints, you should be able to synchronize those threads and make it work flawlessly 😉

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

Sidebar

Related Questions

So I have this php web app, and one of my folder contains some
In my Android App Activity, I have a RelativeLayout with one ImageView and a
I have this .NET web app that draws a table in Page_Load. Then after
I have this c# web app that relies heavily on two dll files that
I have an app that has a list as its main activity and then
I have an android-app with a listview in an activity. The listview has, if
I have a DB that I use in all my activities. There is only
I have written a small app, that has a Activity to control and display
I have an Android widget that has a configure activity. I also have an
I'm working on an android app where I have only 2 activities... The first

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.