OSDN Git Service

1710abbdd891f8093144c693a60d1eb8a2a1e40e
[android-x86/packages-apps-Eleven.git] / src / com / cyanogenmod / eleven / loaders / AsyncHandler.java
1 /*
2  * Copyright (C) 2010 The Android Open Source Project Licensed under the Apache
3  * License, Version 2.0 (the "License"); you may not use this file except in
4  * compliance with the License. You may obtain a copy of the License at
5  * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
6  * or agreed to in writing, software distributed under the License is
7  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8  * KIND, either express or implied. See the License for the specific language
9  * governing permissions and limitations under the License.
10  */
11
12 package com.cyanogenmod.eleven.loaders;
13
14 import android.os.Handler;
15 import android.os.HandlerThread;
16
17 /**
18  * Helper class for managing the background thread used to perform io operations
19  * and handle async broadcasts.
20  */
21 public final class AsyncHandler {
22
23     private static final HandlerThread sHandlerThread = new HandlerThread("AsyncHandler");
24
25     private static final Handler sHandler;
26
27     static {
28         sHandlerThread.start();
29         sHandler = new Handler(sHandlerThread.getLooper());
30     }
31
32     /* This class is never initiated */
33     private AsyncHandler() {
34     }
35
36     /**
37      * @param r The {@link Runnable} to execute.
38      */
39     public static void post(final Runnable r) {
40         sHandler.post(r);
41     }
42
43 }