From today, let's take a look at Android's multithreaded knowledge, Android is easy to get started, but it's not easy to do a perfect product, so let's start with the thread and step into Android.
First, thread based review
Package com.maso.test;
The first way to create the public class Traditionalthread {public static void main (string[] args) {* * * thread
*/Thread Thread1 = new Thread () {@Override public void run () {
try {sleep (1000);
catch (Interruptedexception e) {e.printstacktrace ();
} while (true) {System.out.println (Thread.CurrentThread (). GetName ());
}
}
};
Thread1.start ();
* * * The second way to create a thread thread2 = new Thread (new Runnable () {
@Override public void Run () {try {thread.sleep (1000);
catch (Interruptedexception e) {e.printstacktrace (); } while (true) {System.out.println (Thread.CurrentThread (). GetName ());
}
}
});
Thread2.start ();
* * thread's call priority/new Thread (new Runnable () {@Override
public void Run () {try {thread.sleep (1000);
catch (Interruptedexception e) {e.printstacktrace ();
} while (true) {System.out.println ("Runnable"); }} {public void run () {try {1000
);
catch (Interruptedexception e) {e.printstacktrace ();
} while (true) {System.out.println ("Thread");
} };
}.start (); }
}
The code above is two ways of creating threads that are familiar to us, and if you're unfamiliar with them, look at the Java Thread Basics first.
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/