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 ......
Ò»£®Ñ¡ÔñÌ⣨ÿµÀÌâ3·Ö£¬¹²45·Ö£©
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
£¨1£©ÏÂÁйØÓÚJavaÓïÑÔµÄÌص㣬ÃèÊö´íÎóµÄÊÇ£¨ &nb ......
ÔÚ Java ³ÌÐòÖÐʹÓöàÏß³ÌÒª±ÈÔÚ C »ò C++ ÖÐÈÝÒ׵ö࣬ÕâÊÇÒòΪ Java ±à³ÌÓïÑÔÌṩÁËÓïÑÔ¼¶µÄÖ§³Ö¡£±¾ÎÄͨ¹ý¼òµ¥µÄ±à³ÌʾÀýÀ´ËµÃ÷ Java ³ÌÐòÖеĶàÏß³ÌÊǶàôֱ¹Û¡£¶ÁÍê±¾ÎÄÒÔºó£¬Óû§Ó¦¸ÃÄܹ»±àд¼òµ¥µÄ¶àÏ̳߳ÌÐò¡£
¡¡¡¡ÎªÊ²Ã´»áÅŶӵȴý?
¡¡¡¡ÏÂÃæµÄÕâ¸ö¼òµ¥µÄ Java ³ÌÐòÍê³ÉËÄÏî²»Ïà¹ØµÄÈÎÎñ¡£ÕâÑùµ ......
ÏÈ¿´¿´ÏÂÃæµÄ´úÂ룬´ó¼Ò²Â²ÂÊä³öÊÇʲô
package com.captain.test;
public class ArrayTest {
public static void main(String[] args){
//н¨Ò»¸ö¶ÔÏó£¨OneNum£©Êý×飨¸³ÖµÎª5¡¢3¡¢4£©
OneNum[] ac = {new OneNum(5),new OneNum(3),new OneNum(4)};
//н¨Ò»¸öÓëacͬ³¤¶ÈµÄ¶ÔÏó£¨OneNum£©Êý×é
OneNum[] n ......