java一个多线程的经典例子
import java.io.*;
//多线程编程
public class MultiThread
{
public static void main(String args[])
{
System.out.println("我是主线程!");
//下面创建线程实例thread1
ThreadUseExtends thread1=new ThreadUseExtends();
//创建thread2时以实现了Runnable接口的THhreadUseRunnable类实例为参数
Thread thread2=new Thread(new ThreadUseRunnable(),"SecondThread");
thread1.start();//启动线程thread1使之处于就绪状态
//thread1.setPriority(6);//设置thread1的优先级为6
//优先级将决定cpu空出时,处于就绪状态的线程谁先占领cpu开始运行
//优先级范围1到10,MIN_PRIORITY,MAX_PRIORITY,NORM_PAIORITY
//新线程继承创建她的父线程优先级,父线程通常有普通优先级即5NORM_PRIORITY
System.out.println("主线程将挂起7秒!");
try
{
Thread.sleep(7000);//主线程挂起7秒
}
catch (InterruptedException e)
{
return;
}
System.out.println("又回到了主线程!");
if(thread1.isAlive())
{
thread1.stop();//如果thread1还存在则杀掉他
System.out.println("thread1休眠过长,主线程杀掉了thread1!");
}
else
System.out.println("主线程没发现thread1,thread1已醒顺序执行结束了!");
thread2.start();//启动thread2
System.out.println("主线程又将挂起7秒!");
try
{
Thread.sleep(7000);//主线程挂起7秒
}
catch (InterruptedException e)
{
return;
}
System.out.println("又回到了主线程!");
if(thread2.isAlive())
{
thread2.stop();//如果thread2还存在则杀掉他
System.out.println("thread2休眠过长,主线程杀掉了thread2!");
}
else
System.out.println("主线程没发现thread2,thread2已醒顺序执行结束了!");
System.out.println("程序结束按任意键继续!");
try
{
System.in.read();
}
catch (IOException e)
{
System.out.println(e.toString());
}
}//main
}/
相关文档:
1.创建测试表
create table users(
userid int primary key,
username varchar2(20),
userpwd varchar2(20)
);
insert into users values(1,'test','test');
insert into users values(2,'test','test');
insert into users values(3,'test','test');
insert into users values(4,'test','test');
insert i ......
XSD文件 (XML Schema 语言也称作 XML Schema 定义(XML Schema Definition,XSD)。 具体使用方法和定义请参看:
http://www.w3school.com.cn/schema/index.asp
java自jdk1.5以上新增了SchemaFactory类 可以实现对XSD验证的支持,使用起来也很方便。
以下代码可用在JDK1.5+ 验证xml
public class SimpleErrorHandler i ......
(1) 类名首字母应该大写。字段、方法以及对象(句柄)的首字母应小写。对于所有标识符,其中包含的所有单词都应紧靠在一起,而且大写中间单词的首字母。例如:
ThisIsAClassName
thisIsMethodOrFieldName
若在定义中出现了常数初始化字符,则� ......
这都是我学习JAVA亲身经历的心得,今天花了一个多小时总结出来希望对大家有一定的帮助。如果如总结不妥,请指出和批评!为学习JAVA的初学者铺条学习JAVA的道路
首先大家要明确一点,外面招聘JAVA的,主要是指的J2EE,也就是BS结构(浏览器和服务器结构)JAVA的之所以火起来真是因为BS结构,并不在CS结构,所以那种大型网游 ......
21天学通Java6 下载地址 http://d.download.csdn.net/down/2031000/bolike(只有源代码)
<<21天学通Java 2(第二版)>>(中英文版PDF)+附书源码 下载地址 http://www.zzx8.com/html/c16246.html(似乎中英文的不对应,看中文还是看英文的?) ......