1.继承Thread
public class java_thread extends Thread{
public static void main(String args[])
{
(new java_thread()).run();
System.out.println("main thread run ");
}
public synchronized void run()
{
System.out.println("sub thread run ");
}
}
2.实现Runnable接口
public class java_thread implements Runnable{
public static void main(String args[])
{
(new Thread(new java_thread())).start();
System.out.println("main thread run ");
}
public void run()
{
System.out.println("sub thread run ");
}
}
3.直接在函数体使用
void java_thread()
{
Thread t = new Thread(new Runnable(){
public void run(){
mSoundPoolMap.put(index, mSoundPool.load(filePath, index));
getThis().LoadMediaComplete();
}});
t.start();
}