摘要: 1.创建和启动线程 线程类必须实现Runnable接口或者扩展Thread类,并且实现run方法,run方法没有参数没有返回值不允许抛出异常。调用start实例方法启动一个线程。调用该方法后,线程准备启动,只有获得CPU时,start将自动调用run,线程才真正启动。public class DefineThread { /** * 通过继承java.lang.Thread类定义线程 */ class ThreadA extends Thread{ /** * 当线程被运行时调用此方法 */ public... 阅读全文
posted @ 2011-10-19 11:39 liuping 阅读(179) 评论(0) 推荐(0) 编辑