基础知识
包括定义多线程,线程的访问控制等=》笔记上
vector,stack,hashtable=》propertic,StringBuffer
Properties类是Hashtable的一个子类,hashTable是线程安全的,所以properotes是线程安全的
发生异常会中断线程,当该线程调用sleep()方法时不会终止线程,而抛出异常则会
线程的停止有三种方式:1调用stop()方法,2.线程执行完成,3.异常抛出
jre 判断程序是否执行结束的标准是()
所有的前台线程执行完毕。后台线程为前台线程提供服务。
例一:有以下程序段, 则下面正确的选项是()//不知道哪个线程先运行,先停止,故不稳定
public class MyThead extends Thread{
public static void main(String[] args) {
MyThead t=new MyThead();
MyThead s=new MyThead();
t.start();
System.out.println("one.");
s.start();
System.out.println("two.");
}
public void run() {
System.out.println("Thread");
}
}
正确答案: B C D 你的答案: C (错误)
编译失败
程序运行可能结果为:
one.
Thread
two.
Thread
程序运行可能结果是:
one.
two.
Thread
Thread
程序运行结果不稳定