Thread loop of C++ and Java

Java:
frameworks/base/services/java/com/android/server/SystemServer.java
static class WMThread extends Thread {
WindowManagerService mService;


private final Context mContext;
private final PowerManagerService mPM;
private final boolean mHaveInputMethods;


public WMThread(Context context, PowerManagerService pm,
boolean haveInputMethods) {
super("WindowManager");
mContext = context;
mPM = pm;
mHaveInputMethods = haveInputMethods;
}


public void run() {
Looper.prepare();
WindowManagerService s = new WindowManagerService(mContext, mPM,
mHaveInputMethods);
android.os.Process.setThreadPriority(
android.os.Process.THREAD_PRIORITY_DISPLAY);
android.os.Process.setCanSelfBackground(false);


synchronized (this) {
mService = s;
notifyAll();
}


Looper.loop();
}
}




C++:
frameworks/base/libs/ui/InputDispatcher.cpp
bool InputDispatcherThread::threadLoop() {  
    mDispatcher->dispatchOnce();  
    return true;  
}  


also, for C++, we should look into the nativeactivity code later.

你可能感兴趣的:(java,thread,C++,c,Class)