java¶àÏß³Ìѧϰ
package thread;
public class ThreadTest {
public static void main(String args[])
{
//new TestThread ().start();
TestThread tt= new TestThread();//´´½¨TestThreadÀàµÄÒ»¸öʵÀý
Thread t= new Thread(tt);//´´½¨Ò»¸öThreadÀàµÄʵÀý
t.start();//ʹÏ߳̽øÈëRunnable״̬
new Thread(tt).start();
int i = 100;
while(i-- > 0)
{
System.out.println("main thread is running");
}
}
}
class TestThread implements Runnable //extends Thread
{
int ticket = 100;
public void run()//Ï̵߳ĴúÂë¶Î£¬µ±Ö´ÐÐstart()ʱ£¬Ï̴߳Ӵ˳ö¿ªÊ¼Ö´ÐÐ
{
while(ticket > 0)
{
System.out.println(Thread.currentThread().getName() +
" is running " + ticket);
ticket--;
}
}
}
Ïà¹ØÎĵµ£º
¼òµ¥À´Ëµ£¬ ½Ó¿ÚÊǹ«¿ªµÄ£¬ÀïÃæ²»ÄÜÓÐ˽Óеķ½·¨»ò±äÁ¿£¬ÊÇÓÃÓÚÈñðÈËʹÓõģ¬¶ø³éÏóÀàÊÇ¿ÉÒÔÓÐ˽Óз½·¨»ò˽ÓбäÁ¿µÄ£¬ÁíÍ⣬ʵÏÖ½Ó¿ÚµÄÒ»¶¨ÒªÊµÏÖ½Ó¿ÚÀﶨÒåµÄËùÓз½·¨£¬¶øʵÏÖ³éÏóÀà¿ÉÒÔÓÐÑ¡ÔñµØÖØдÐèÒªÓõ½µÄ·½·¨¡£
Ò»°ãµÄÓ¦ÓÃÀ×¼¶µÄÊǽӿڣ¬È»ºóÊdzéÏóÀàʵÏÖ½Ó¿Ú£¬×îºó²Åµ½¾ßÌåÀàʵÏÖ¡£
»¹ÓУ¬½Ó¿Ú¿ÉÒÔʵÏÖ¶àÖ ......
JavaÓÐÁ½ÖÖThread£º“ÊØ»¤Ïß³ÌDaemon”Óë“Óû§Ïß³ÌUser”¡£
ÎÒÃÇ֮ǰ¿´µ½µÄÀý×Ó¶¼ÊÇÓû§£¬ÊØ»¤Ïß³ÌÊÇÒ»ÖÖ“ÔÚºǫ́ÌṩͨÓÃÐÔÖ§³Ö”µÄỊ̈߳¬Ëü²¢²»ÊôÓÚ³ÌÐò±¾Ìå¡£
´Ó×ÖÃæÉÏÎÒÃǺÜÈÝÒ×½«ÊØ»¤Ïß³ÌÀí½â³ÉÊÇÓÉÐéÄâ»ú£¨virtual machine£©ÔÚÄÚ²¿´´½¨µÄ£¬¶øÓû§Ïß³ÌÔòÊÇ×Ô¼ºËù´´½¨µÄ¡£ÊÂʵ²¢²»Ê ......
ºÜ¶àÈ˶¼ÖªµÀÔÚswingÖмÓÈëjPopupMenu×é¼þºó¿ÉÒÔÔÚÊó±êµÄÇý¶¯ÏÂ̽³öÒ»¸ö²Ëµ¥£¬µ«ÊÇ£¬Èç¹ûÓÃÒ»°ã×ö·¨£¬ÔÚ½çÃæÉϵ¥»÷×ó¼üÒ²»áµ¯³ö²Ëµ¥£¬ÄÇôÓÐûÓа취ÔÚÖ»Óе¥»÷ÓÒ¼ü²Åµ¯³ö²Ëµ¥ÄØ£¿ÆäʵֻÊÇÓõ½ÁËÒ»¸öС¼¼ÇÉ¡£ ÄãµÄµ¯³öÊó±ê²Ëµ¥Êó±êÇý¶¯Ñ¡Ôñ MouseReleased È»ºóÔÙÔÚ¼àÌýʼþµÄ·½·¨ÖмÓÈëÏÂÃæµÄ´úÂë¾Í¿ÉÒÔÁË£º if(evt.isPop ......
1. JavaÖгýÁËstaticºÍfinal·½·¨Í⣬ÆäËûËùÓеķ½·¨¶¼ÊÇÔËÐÐʱ°ó¶¨µÄ¡£private·½·¨¶¼±»Òþʽָ¶¨ÎªfinalµÄ£¬Òò´ËfinalµÄ·½·¨²»»áÔÚÔËÐÐʱ°ó¶¨¡£µ±ÔÚÅÉÉúÀàÖÐÖØд»ùÀàÖÐstatic¡¢final¡¢»òprivate·½·¨Ê±£¬ÊµÖÊÉÏÊÇ´´½¨ÁËÒ»¸öеķ½·¨¡£
2.ÔÚÅÉÉúÀàÖУ¬¶ÔÓÚ»ùÀàÖеÄpr ......
»º³åÇøÄÚ²¿Ï¸½Ú
״̬±äÁ¿
״̬±äÁ¿ÊÇÇ°Ò»½ÚÖÐÌáµ½µÄ"ÄÚ²¿Í³¼Æ»úÖÆ"µÄ¹Ø¼ü¡£Ã¿Ò»¸ö¶Á/д²Ù×÷¶¼»á¸Ä±ä»º³åÇøµÄ״̬¡£Í¨¹ý¼Ç¼ºÍ¸ú×ÙÕâЩ±ä»¯£¬»º³åÇø¾ÍÄܹ»ÄÚ²¿µØ¹ÜÀí×Ô¼ºµÄ×ÊÔ´¡£
¿ÉÒÔÓÃÈý¸öÖµÖ¸¶¨»º³åÇøÔÚÈÎÒâʱ¿ÌµÄ״̬£º
position
limit
capacity
Position
»º³åÇøʵ¼ÊÉϾÍÊÇÃÀ»¯Á˵ÄÊý×é¡£ÔÚ´ÓͨµÀ¶Áȡʱ£¬Äú ......