摘要: 1 package test; 2 3 4 /*System类 5 * 6 * public static void gc() 运行垃圾回收器 只有在执行大量的对象的释放,才调用垃圾回收。 7 * public static void exit(int sta... 阅读全文
posted @ 2015-08-24 11:06 chengling 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 1 package test; 2 import java.util.Random; 3 /* 4 * Random类 5 * 此类用于产生随机数 6 * 构造方法: 7 * public Random():没有种子,用的是默认种子,是当前时间的毫秒值 8 * ... 阅读全文
posted @ 2015-08-24 09:22 chengling 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1 package test; 2 3 /* 4 *Math:数学运算 5 * 成员变量 6 * PI E 7 * 8 * 成员方法 9 * public static int abs(int a) 绝对值10 * public static ... 阅读全文
posted @ 2015-08-24 09:21 chengling 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 1 package test; 2 3 import java.util.Timer; 4 import java.util.TimerTask; 5 6 /* 7 * 定时器:可以让我们在指定的时间做某件事情,还可以重复的做某件事情。 8 * 依赖Timer和TimerTask这两个类 ... 阅读全文
posted @ 2015-08-23 15:01 chengling 阅读(336) 评论(0) 推荐(0) 编辑
摘要: 1 package test; 2 3 //匿名内部类实现多线程 4 public class Test01{ 5 public static void main(String[] args) { 6 new Thread(){ 7 public ... 阅读全文
posted @ 2015-08-23 14:34 chengling 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 1 package test; 2 3 import java.util.concurrent.ExecutorService; 4 import java.util.concurrent.Executors; 5 6 /* 7 * 程序启动一个新线程成本是比较高的,因为它涉及到要与操作系统... 阅读全文
posted @ 2015-08-23 14:26 chengling 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 1 package test; 2 3 public class Test01{ 4 public static void main(String[] args) { 5 Student s=new Student(); 6 7 SetT... 阅读全文
posted @ 2015-08-23 11:51 chengling 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 线程组 1 package test; 2 3 /*线程组 4 * 默认情况下,所有线程都是属于主线程组main 5 * 6 * */ 7 8 public class Test01 { 9 public static void main(String[] args) {10 ... 阅读全文
posted @ 2015-08-23 11:09 chengling 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 等待唤醒机制 1 package test; 2 3 /* 4 * 生产者消费者问题 5 * 分析: 6 * 资源类:Student 7 * 设置学生数据:SetThread(生产者) 8 * 获取学生数据:GetT... 阅读全文
posted @ 2015-08-23 10:52 chengling 阅读(159) 评论(0) 推荐(0) 编辑
摘要: Lock锁 1 package test; 2 3 public class Test01{ 4 public static void main(String[] args) { 5 MyRunnable mr=new MyRunnable(); 6 Thr... 阅读全文
posted @ 2015-08-23 09:31 chengling 阅读(160) 评论(0) 推荐(0) 编辑