javaÏß³Ì
1.Ï̴߳´½¨µÄÁ½ÖÖ·½Ê½
1£©À©Õ¹ThreadÀಢÖØдpublic void run()·½·¨
ps£º
¶¨ÒåỊ̈߳º
class myThread extends Thread(){
public void run(){
System.out.println("Just working !");
}
}
ʵÀý»¯£º
myThread t=new myThread();
Æô¶¯£º
t.start();
2£©µ÷ÓôøRunnable±äÔªµÄThread¹¹Ô캯Êý
ps:
¶¨ÒåỊ̈߳º
class myRunnable implements Runnable{
public void run(){
System.out.println("Just working !");
}
}
ʵÀý»¯£º
myRunnable r=new myRunnable();
Thread t=new Thread(r);
Æô¶¯£º
t.start();
2.ThreadÀà³£Ó÷½·¨
1£©ThreadÀàÖг£ÓÃÖØÔع¹Ô캯Êý£º
Thread()
Thread(Runnable target)
Thread(Runnable target,String name)
Thread(String name)
2£©setName() ÉèÖÃÏß³ÌÃû³Æ
getName() »ñµÃÏß³ÌÃû³Æ
sleep() ±£Ö¤µ±Ç°Ïß³ÌÖÁÉÙÔÚÖ¸¶¨µÄ˯Ãßʱ¼äÍ£Ö¹Ö´ÐÐ
yield() ʹµ±Ç°ÔËÐÐÖеÄÏ̻߳ص½¿ÉÔËÐÐ״̬£¬²¢Ê¹ÏàͬÓÅÏȼ¶µÄÏß³ÌÓлú»áÔËÐУ¬µ«²»±£Ö¤
join() ±£Ö¤µ±Ç°Ïß³ÌÍ£Ö¹Ö´ÐУ¬Ö±µ½ËûËù¼ÓÈëµÄÏß³ÌÍê³ÉΪֹ
3£©Ö÷ÒªÏ̷߳½·¨
ObjectÀà ThreadÀà Runnable½Ó¿Ú
wait() start() run()
notify() yield() (¾²Ì¬)
notifyAll() sleep()(¾²Ì¬)
jion()
3.Ïß³Ì״̬Óëת±ä
ÐÂ״̬-->¿ÉÔËÐÐ״̬<-->Ô
Ïà¹ØÎĵµ£º
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......
ʹÓÃBigInteger´óÈÝÁ¿ÔËËãÀà¼ÆËã100µÄ½×³Ë
Ò».Ò»°ãËã·¨(Ñ»·)
public class Test {
public static void main(String[] args) {
int result = 1;
for (int i = 1; i <= 100; i++) {
result *= i;
}
System.out.println(result);
}
}
Êä³ö½á¹ûΪ0£¬ÒòΪintÎÞ·¨±£´æÏÂ100µÄ½×³ËµÄ½á¹û£¬100µ ......
ÔÚJAVAƽ̨,ʵÏÖÒì²½µ÷ÓõĽÇÉ«ÓÐÈçÏÂÈý¸ö½ÇÉ«:µ÷ÓÃÕß Ìá»õµ¥ ÕæʵÊý¾Ý
Ò»¸öµ÷ÓÃÕßÔÚµ÷ÓúÄʱ²Ù×÷,²»ÄÜÁ¢¼´·µ»ØÊý¾Ýʱ,ÏÈ·µ»ØÒ»¸öÌá»õµ¥.È»ºóÔÚ¹ýÒ»¶Ïʱ¼äºóƾÌá»õµ¥À´»ñÈ¡ÕæÕýµÄÊý¾Ý.
È¥µ°¸âµêÂòµ°¸â£¬²»ÐèÒªµÈµ°¸â×ö³öÀ´£¨¼ÙÉèÏÖ×öÒªºÜ³¤Ê±¼ä£©£¬Ö»ÐèÒªÁì¸öÌá»õµ¥¾Í¿ÉÒÔÁË£¨È¥¸É±ðµÄÊÂÇ飩£¬µÈµ½µ°¸â×öºÃÁË£¬ÔÙÄÃÌá»õµ¥ ......
Ò»¡¢Îª´úÂë¼Ó×¢ÊÍ¡£ËäȻÿ¸öÈ˶¼ÖªµÀÕâµã£¬µ«ÓÐʱȴ²»×Ô¾õÍüÁËÂÄÐУ¬½ñÌìÄã“ÍüÁË”¼Ó×¢ÊÍÁËÂð£¿ËäÈ»×¢ÊͶԳÌÐòµÄ¹¦ÄÜûʲô“¹±Ï×”£¬µ«¹ýÒ»¶Îʱ¼ä£¬±ÈÈç˵Á½ÐÇÆÚÖ®ºó»òÕ߸ü³¤£¬»Ø¹ýÍ·À´¿´¿´×Ô¼ºµÄ´úÂ룬˵²»¶¨ÒѾ¼Ç²»×¡ËüÊǸÉʲôµÄÁË¡£Èç¹ûÕâЩ´úÂëÊÇÄã¸öÈ˵ģ¬ÄÇ»¹ËãÊÇ×ßÔËÁË£¬²»ÐÒµÄÊÇ£¬µ± ......
½Ì³Ì5 ËãÊýÔËËãѧϰ³ÌÐò ѧϰĿ±ê 5.1¼òµ¥¼Ó·¨Ñ§Ï°³ÌÐò СѧÉúÔÚ¸Õ¸Õ¿ªÊ¼Ñ§Ï°ÊýѧÔËËãµÄʱºò£¬ÐèÒª²»¶ÏµØ½øÐз´¸´´óÁ¿µÄÁ·Ï°£¬²ÅÄܹ»Ñ¸ËÙÕÆÎÕÕⲿ·ÖÄÚÈÝ¡£ÏÂÃ濪·¢Ò»¸ö¼òµ¥µÄ¼Ó·¨Ñ§Ï°³ÌÐò£¬Äܹ»²úÉú¼Ó·¨ÔËËãÈÃѧÉúÀ´Ñ§Ï°Ìá¸ß¡£ ±àд³ÌÐòÈçÏ£º 1 package lesson5; 2 3 public class Operation1 { 4 int number1; 5 ......