๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์นดํ…Œ๊ณ ๋ฆฌ ์—†์Œ

[Android] deprecated AsyncTask ์ˆ˜์ • > Executors ์ด์šฉํ•˜๊ธฐ

https://ittutorialpoint.com/the-asynctask-api-is-deprecated-in-android-11-what-are-the-alternatives/?quad_cc 

 

The AsyncTask API is deprecated in Android 11. What are the alternatives?

You can directly use Executors from java.util.concurrent package.I also searched about it and I found a solution in this Android Async API is

ittutorialpoint.com

Solution 2 ๋ฐฉ๋ฒ•์„ ์ด์šฉํ–ˆ์Œ.

 

ExecutorService executor = Executors.newSingleThreadExecutor();
Handler handler = new Handler(Looper.getMainLooper());

executor.execute(new Runnable() {
    @Override
    public void run() {

        //Background work here

        handler.post(new Runnable() {
            @Override
            public void run() {
                //UI Thread work here
            }
        });
    }
});