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
Ïà¹ØÎĵµ£º
Java ʹµÃ¸´ÔÓÓ¦ÓõĿª·¢±äµÃÏà¶Ô¼òµ¥£¬ºÁÎÞÒÉÎÊ£¬ËüµÄÕâÖÖÒ×ÓÃÐÔ¶ÔJavaµÄ´ó·¶Î§Á÷Ðй¦²»¿Éû¡£È»¶ø£¬ÕâÖÖÒ×ÓÃÐÔʵ¼ÊÉÏÊÇÒ»°ÑË«Èн£¡£Ò»¸öÉè¼ÆÁ¼ºÃµÄ Java³ÌÐò£¬ÐÔÄܱíÏÖÍùÍù²»ÈçÒ»¸öͬÑùÉè¼ÆÁ¼ºÃµÄC++³ÌÐò¡£ÔÚJava³ÌÐòÖУ¬ÐÔÄÜÎÊÌâµÄ´ó²¿·ÖÔÒò²¢²»ÔÚÓÚJavaÓïÑÔ£¬¶øÊÇÔÚÓÚ³ÌÐò±¾Éí¡£Ñø³ÉºÃµÄ´úÂë±àдϰ¹ß·Ç³£ÖØÒª£¬±ÈÈçÕ ......
AntÓ÷¨——Õª×Ô¡¶ÇáÁ¿¼¶Java EEÆóÒµÓ¦ÓÃʵս¡·
1.6 AntµÄ°²×°ºÍʹÓÃ
AntÊÇÒ»ÖÖ»ùÓÚJavaµÄÉú³É¹¤¾ß
¡£´Ó×÷ÓÃÉÏÀ´¿´£¬ËüÓÐЩÀàËÆÓÚC±à³Ì£¨Unixƽ̨ÉÏʹÓý϶ࣩÖеÄMake¹¤¾ß£¬C/C++ÏîÄ¿
¾³£Ê¹ÓÃMake¹¤¾ßÀ´¹ÜÀíÕû¸öÏîÄ¿µÄ±àÒë¡¢Éú³É¡£
MakeʹÓÃShellÃüÁîÀ´¶¨Òå
Éú³ÉÈÎÎñ£¬²¢¶¨ÒåÈÎÎñÖ®¼äµÄÒÀÀµ¹Øϵ£¬ÒÔ±ãË ......
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 ......
¶¨Ê±Æ÷ÀàTimerÔÚjava.util°üÖС£Ê¹ÓÃʱ£¬ÏÈʵÀý»¯£¬È»ºóʹÓÃʵÀýµÄschedule(TimerTask task, long delay)·½·¨£¬É趨ָ¶¨µÄÈÎÎñtaskÔÚÖ¸¶¨µÄÑÓ³ÙdelayºóÖ´ÐС£¶¨Ê±Æ÷ÈÎÎñÀàTimerTaskÊdzéÏóÀ࣬¼Ì³Ð²¢ÖØдÆärun()·½·¨£¬¿ÉʵÏÖ¾ßÌåÈÎÎñ¡£
schedule(TimerTask task, Date time)É趨ָ¶¨ÈÎÎñtaskÔÚÖ¸¶¨Ê±¼ätimeÖ´ÐС£
cancel ......
½ñÌì³é¿ÕÏÂÁË¡¶java½â»ó¡·Õâ±¾Êé¿´ÁËһϣ¬È·Êµ²»´í£¬Ìá³öÁ˺ܶàÎÒÃÇƽʱ²»»á×¢ÒâµÄСÎÊÌâ¡£ÏëÏëÈç¹û²»×¢Òâ˵²»¶¨»áÒòΪһ¸öBUGÓôÃƸöÒ»Á½ÌìÒ²ÕÒ²»µ½¡£ÒÔÏÂÊÇ×ܽáµÄ±Ê¼Ç£¬±¸Íü~~
1.ÅжÏÆæÊý
i % 2 == 1 ÔÚi Ϊ¸ºÊýʱ½á¹ûΪ-1£¬ËùÒÔʹÓÃi % 2 != 0À´Åжϣ»µ±ÓÐÐÔÄÜÒªÇóʱʹÓà (i & 1) != 0¡£
*ÔÚʹÓÃ%ʱһ¶¨Òª¿¼Âǵ ......