摘要:
非静态同步方法如果使用synchronized来锁定类中所有的同步非静态方法,只需要使用this作为synchronized块的参数传入synchronized块中 1 public class Test 2 { 3 public void method1() 4 { 5 synch... 阅读全文
摘要:
线程创建线程方式一:继承Thread类A extends Thread覆盖Thread中的run方法,将线程的任务代码封装到run方法中。在主函数中: A a = new A(); a.start() //创建并启动线程创建线程方式二:实现Runnable接口Class A implem... 阅读全文