Java notify() and notifyAll() test
Java代码
final TC[] ts = new TC[20];
for (int i = 0; i < ts.length; i++) {
TC target = new TC("TC " + i, SYNC1);
Thread thread = new Thread(target);
ts[i] = target;
thread.start();
}
final TC[] ts = new TC[20];
for (int i = 0; i < ts.length; i++) {
TC target = new TC("TC " + i, SYNC1);
Thread thread = new Thread(target);
ts[i] = target;
thread.start();
}
------------------------------------------------------------
接下来马上启动另外一个线程用于做notify操作。
Java代码
// 一个用于停止的Thread
new Thread(new Runnable() {
public void run() {
synchronized (SYNC1) {
int i = 10;
while (i > 0) {
&nbs
相关文档:
Inner classes, also called Nested Classes, are nothing but classes that are defined within other classes. The nesting is a relationship between classes, not objects.
Inner classes have clearly two benefits, name control & access control. In Java, this benefit is not as important because Java pa ......
第一,谈谈final, finally, finalize的区别。
final—修饰符(关键字)如果一个类被声明为final,意味着它不能再派生出新的子类,不能作为父类被继承。因此一个类不能既被声明为
abstract的,又被声明为final的。将变量或方法声明为final,可以保证它们在使用中不被改变。被声明为final的变量必须在声明时给定
......
import java.awt.*;
import java.awt.event.*;
public class TestFrame {
Frame fm = new Frame();
public void init(){
fm.setSize(300,300);
Button btn = new Button("ok");
fm.add(btn);
btn.addActionListener(ne ......
请不要把你的学习Java之路和其它计算机技术分开看待,技术的联系往往是千丝万缕的,你应该掌握一些学习Java所涉及的基础知识,对于 “CLASSPATH要怎么设置啊”、“跪求JDK下载地址”等等问题,你不该问,因为Internet上太多答案了,甚至换个角度说,你是不是还不适合直接学习编程?
1)买本Java学习用 ......