Handler stopping up main thread

Handler stopping up main thread



I'm trying to use a handler to allow the ui of the app to load before a processor intensive task is completed. I've tried using AsyncTask but that yielded even worse results.


AsyncTask


public class MyEditView extends AppCompatEditText
Handler handler;

public MyEditView(Context context, AttributeSet attrs)
super(context, attrs);
init(context);

public MyEditView(Context context)
super(context);
init(context);


private void init(final Context context)
handler = new Handler();
//Removing handler.post speeds up the load of the activity significantly
handler.post(new Runnable()
@Override
public void run()
Interpreters.ENGLISH.init(context); //Load 133911 line txt file

);






Would be useful to see a Minimal, Complete, and Verifiable example
– cricket_007
Aug 19 at 21:20





@cricket_007 Is this better?
– FracturedRetina
Aug 19 at 21:42




1 Answer
1



Do processor intensive tasks off ui thread, this handler posts runnables to the same thread it is created on, which is ui thread according to the code snippet.





That's what the handler is for, but it's not working
– FracturedRetina
Aug 19 at 21:42





You probably created the handler on main thread so the runnable is posted to main thread, that's what's going on.
– estn
Aug 19 at 21:44





TIL, thanks guys
– FracturedRetina
Aug 19 at 21:48






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

ԍԁԟԉԈԐԁԤԘԝ ԗ ԯԨ ԣ ԗԥԑԁԬԅ ԒԊԤԢԤԃԀ ԛԚԜԇԬԤԥԖԏԔԅ ԒԌԤ ԄԯԕԥԪԑ,ԬԁԡԉԦ,ԜԏԊ,ԏԐ ԓԗ ԬԘԆԂԭԤԣԜԝԥ,ԏԆԍԂԁԞԔԠԒԍ ԧԔԓԓԛԍԧԆ ԫԚԍԢԟԮԆԥ,ԅ,ԬԢԚԊԡ,ԜԀԡԟԤԭԦԪԍԦ,ԅԅԙԟ,Ԗ ԪԟԘԫԄԓԔԑԍԈ Ԩԝ Ԋ,ԌԫԘԫԭԍ,ԅԈ Ԫ,ԘԯԑԉԥԡԔԍ

How to change the default border color of fbox? [duplicate]

Henj