//反射
/*Class> clazz = Class.forName("cn.lpf.threadDemo.ReflectPoint");
Field fieldx = clazz.getField("x");
Field fieldy = clazz.getField("y");
Object obj = clazz.newInstance();
fieldx.setAccessible(true);
fieldx.set(obj, 10);
System.out.println("获取字段:"+fieldx);
System.out.println("字段的值 x=:"+ fieldx.getInt(obj));
System.out.println("字段的值 y=:"+fieldy.getInt(obj));
Method drawCricle = clazz.getMethod("sayHello", String.class);
String str = (String) drawCricle.invoke(obj, "HelloWorld");
System.out.println(str);
Method[] methods = clazz.getMethods();
System.out.println("所有的方法集合");
for (int i = 0 ; i
System.out.println("方法名:"+methods[i]);
for (int j = 0;j
}
}*/
//ArrayList
/*List
list.add("老公");
list.add("老婆 ");
for (String str : list){
System.out.println(str);
}
Map
map.put("lpf", "刘朋飞");
map.put("lsm", "卢树敏");
*/
/*System.out.println("9*9乘法口决表");
for ( int i = 1 ; i<=9 ;i++){
for (int j = 1 ;j<=i ;j++){
System.out.print(j+"*"+i+"="+(i*j)+" ");
}
System.out.println();
}*/
//多线程
/*Thread thread = new Thread(){
@Override
public void run(){
while (true ){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
new Timer().schedule(new TimerTask(){
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
Map
map.put("lpf", 10);
map.put("lsm", 20);
if(map.get("lpf")> 10){
System.out.println("刘朋飞的成绩");
}
else{
for ( int i = 1 ; i<=9 ; i++){
for ( int j = 1 ; j<=9; j++){
if (j<=i)
System.out.print(j+"*"+i+"="+(i*j) + " ");
}
System.out.println();
}
}
System.out.println("\r\n\r\n");
}
}, 1 , 1);
}
}
};
thread.start();
//第二个线程
Thread thread2 = new Thread(new Runnable() {
@Override
public void run() {
while (true ){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
new Timer().schedule(new TimerTask(){
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
Map
map.put("lpf", 10);
map.put("lsm", 20);
if(map.get("lpf")> 10){
System.out.println("刘朋飞的成绩");
}
else{
for ( int i = 1 ; i<=9 ; i++){
for ( int j = 1 ; j<=9; j++){
if (j<=i)
System.out.print(j+"*"+i+"="+(i*j) + " ");
}
System.out.println();
}
}
System.out.println("\r\n\r\n");
}
}, 1 , 1);
}//Trandition
}
});
thread2.start();
//第三个线程
Thread thread3 = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
new Timer().schedule(new TimerTask(){
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
Map
map.put("lpf", 10);
map.put("lsm", 20);
if(map.get("lpf")> 10){
System.out.println("刘朋飞的成绩");
}
else{
for ( int i = 1 ; i<=9 ; i++){
for ( int j = 1 ; j<=9; j++){
if (j<=i)
System.out.print(j+"*"+i+"="+(i*j) + " ");
}
System.out.println();
}
}
System.out.println("\r\n\r\n");
}
}, 1 , 1);
}
}){
};
thread3.start();
//第四个线程
Thread thread4 = new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
new Timer().schedule(new TimerTask(){
@Override
public void run() {
// System.out.println(thread4.getName());
Map
map.put("lpf", 10);
map.put("lsm", 20);
if(map.get("lpf")> 10){
System.out.println("刘朋飞的成绩");
}
else{
for ( int i = 1 ; i<=9 ; i++){
for ( int j = 1 ; j<=9; j++){
if (j<=i)
System.out.print(j+"*"+i+"="+(i*j) + " ");
}
System.out.println();
}
}
System.out.println("\r\n\r\n");
}
}, 1 , 1);
}
});
thread4.start();*/