javaÖÐyield(),sleep()ÒÔ¼°wait()µÄÇø±ð
ÍùÍù»ìÏýÁËÕâÈý¸öº¯ÊýµÄʹÓá£
´Ó²Ù×÷ϵͳµÄ½Ç¶È½²£¬os»áά»¤Ò»¸öready queue£¨¾ÍÐ÷µÄÏ̶߳ÓÁУ©¡£²¢ÇÒÔÚijһʱ¿ÌcpuֻΪready queueÖÐλÓÚ¶ÓÁÐÍ·²¿µÄÏ̷߳þÎñ¡£
µ«Êǵ±Ç°ÕýÔÚ±»·þÎñµÄÏ߳̿ÉÄܾõµÃcpuµÄ·þÎñÖÊÁ¿²»¹»ºÃ£¬ÓÚÊÇÌáÇ°Í˳ö£¬Õâ¾ÍÊÇyield¡£
»òÕßµ±Ç°ÕýÔÚ±»·þÎñµÄÏß³ÌÐèҪ˯һ»á£¬ÐÑÀ´ºó¼ÌÐø±»·þÎñ£¬Õâ¾ÍÊÇsleep¡£
sleep·½·¨²»ÍƼöʹÓ㬿ÉÓÃwait¡£
Ïß³ÌÍ˳ö×îºÃ×Ô¼ºÊµÏÖ£¬ÔÚÔËÐÐ״̬ÖÐÒ»Ö±¼ìÑéÒ»¸ö״̬£¬Èç¹ûÕâ¸ö״̬ΪÕ棬¾ÍÒ»Ö±ÔËÐУ¬Èç¹ûÍâ½ç¸ü¸ÄÁËÕâ¸ö״̬±äÁ¿£¬ÄÇôÏ߳̾ÍÍ£Ö¹ÔËÐС£
sleep()ʹµ±Ç°Ï߳̽øÈëÍ£ÖÍ״̬£¬ËùÒÔÖ´ÐÐsleep()µÄÏß³ÌÔÚÖ¸¶¨µÄʱ¼äÄڿ϶¨²»»áÖ´ÐУ»yield()Ö»ÊÇʹµ±Ç°Ïß³ÌÖØлص½¿ÉÖ´ÐÐ״̬£¬ËùÒÔÖ´ÐÐyield()µÄÏß³ÌÓпÉÄÜÔÚ½øÈëµ½¿ÉÖ´ÐÐ״̬ºóÂíÉÏÓÖ±»Ö´ÐС£
sleep()¿ÉʹÓÅÏȼ¶µÍµÄÏ̵߳õ½Ö´ÐеĻú»á£¬µ±È»Ò²¿ÉÒÔÈÃͬÓÅÏȼ¶ºÍ¸ßÓÅÏȼ¶µÄÏß³ÌÓÐÖ´ÐеĻú»á£»yield()Ö»ÄÜʹͬÓÅÏȼ¶µÄÏß³ÌÓÐÖ´ÐеĻú»á¡£
µ±µ÷ÓÃwait()ºó£¬Ï̻߳áÊͷŵôËüËùÕ¼ÓеēËø±êÖ¾”£¬´Ó¶øʹÏß³ÌËùÔÚ¶ÔÏóÖеÄÆäËüsynchronizedÊý¾Ý¿É±»±ðµÄÏß³ÌʹÓá£
waite()ºÍnotify()ÒòΪ»á¶Ô¶ÔÏóµÄ“Ëø±êÖ¾”½øÐвÙ×÷£¬ËùÒÔËüÃDZØÐëÔÚsynchronizedº¯Êý»òsynchronized¡¡blockÖнøÐе÷Óá£Èç¹ûÔÚnon-synchronizedº¯Êý»ònon-synchronized¡¡blockÖнøÐе÷Óã¬ËäÈ»ÄܱàÒëͨ¹ý£¬µ«ÔÚÔËÐÐʱ»á·¢ÉúIllegalMonitorStateExceptionµÄÒì³£¡£
³¹µ×Ã÷°×¶àÏß³ÌͨÐÅ»úÖÆ£º
Ï̼߳äµÄͨÐÅ
1. Ï̵߳ļ¸ÖÖ״̬
Ïß³ÌÓÐËÄÖÖ״̬£¬ÈκÎÒ»¸öÏ߳̿϶¨´¦ÓÚÕâËÄÖÖ״̬ÖеÄÒ»ÖÖ£º
1) ²úÉú£¨New£©£ºÏ̶߳ÔÏóÒѾ²úÉú£¬µ«ÉÐδ±»Æô¶¯£¬ËùÒÔÎÞ·¨Ö´ÐС£Èçͨ¹ýnew²úÉúÁËÒ»¸öÏ̶߳ÔÏóºóû¶ÔËüµ÷ÓÃstart()º¯Êý֮ǰ¡£
2) ¿ÉÖ´ÐУ¨Runnable£©£ºÃ¿¸öÖ§³Ö¶àÏ̵߳Äϵͳ¶¼ÓÐÒ»¸öÅųÌÆ÷£¬ÅųÌÆ÷»á´ÓÏ̳߳ØÖÐÑ¡ÔñÒ»¸öÏ̲߳¢Æô¶¯Ëü¡£µ±Ò»¸öÏ̴߳¦ÓÚ¿ÉÖ´ÐÐ״̬ʱ£¬±íʾËü¿ÉÄÜÕý´¦ÓÚÏ̳߳ØÖеȴýÅÅÅųÌÆ÷Æô¶¯Ëü£»Ò²¿ÉÄÜËüÒÑÕýÔÚÖ´ÐС£ÈçÖ´ÐÐÁËÒ»¸öÏ̶߳ÔÏóµÄstart()·½·¨ºó£¬Ï߳̾ʹ¦ÓÚ¿ÉÖ´ÐÐ״̬£¬µ«ÏÔ¶øÒ×¼ûµÄÊÇ´ËʱÏ̲߳»Ò»¶¨ÕýÔÚÖ´ÐÐÖС£
3) ËÀÍö£¨Dead£©£ºµ±Ò»¸öÏß³ÌÕý³£½áÊø£¬Ëü±ã´¦ÓÚËÀÍö״̬¡£ÈçÒ»¸öÏ̵߳Ärun()º¯ÊýÖ´ÐÐÍê±ÏºóÏ߳̾ͽøÈëËÀÍö״̬¡£
4) Í£ÖÍ£¨Blocked£©£ºµ±Ò»¸öÏ̴߳¦ÓÚÍ£ÖÍ״̬ʱ£¬ÏµÍ³ÅųÌÆ÷
Ïà¹ØÎĵµ£º
±¾ÎÄÊÇÓÉJRÖ÷³Öд×÷µÄ¡¶J2SE½ø½×¡·Ò»ÊéµÄ²¿·ÖÕ½ÚÕûÀí¶ø³É£¬¡¶J2SE½ø½×¡·ÕýÔÚд×÷¡¢ÍêÉƽ׶Ρ£ÄúÔĶÁºó£¬ÓÐÈκν¨Òé¡¢ÅúÆÀ£¬ÇëºÍÎÒÁªÏµ£¬»òÔÚhttp://www.javaresearch.org/forum/thread.jsp?column=376&thread=7576' target='_blank' class='l2'>Õâ¶ùÁôÑÔ¡£¡¶J2SE½ø½×¡·Ð´×÷ÏîÄ¿×é¸ÐлÄúÔĶÁ±¾ÎÄ¡£
ÔÚµ±½ñÕ ......
public static Class[] getClasses(String pckgname)
throws ClassNotFoundException {
ArrayList<Class> classes = new ArrayList<Class>();
// Get a File object for the package
File directory = null;
try {
  ......
--°ü
create or replace package pkg_query as
type cur_query is ref cursor;
end pkg_query;
--¹ý³Ì
CREATE OR REPLACE PROCEDURE "PRC_QUERY" (p_tableName
in varchar2, --±íÃû
& ......
¡¡finalÀࣺΪ·ÀÖ¹ËûÈË´ÓÄãµÄÀàÉÏÅÉÉúÐÂÀ࣬´ËÀàÊDz»¿ÉÀ©Õ¹µÄ¡£
¡¡¡¡¶¯Ì¬µ÷ÓñȾ²Ì¬µ÷Óû¨·ÑµÄʱ¼äÒª³¤¡£
¡¡¡¡³éÏóÀࣺ¹æ¶¨Ò»¸ö»ò¶à¸ö³éÏó·½·¨µÄÀà±¾Éí±ØÐ붨ÒåΪabstract¡£
¡¡¡¡Àý£º public abstract string getDescripition
¡¡¡¡JavaÖеÄÿһ¸öÀ඼ÊÇ´ÓObjectÀàÀ©Õ¹¶øÀ´µÄ¡£
¡¡¡¡objectÀàÖеÄequalºÍtoString·½·¨¡ ......
Ò»¸ö¼òµ¥Ê¾Àý--
1£¬×¼±¸£ºMySQLÊý¾Ý¿âÇý¶¯°ü¡¾mysql-connector-java-5.1.10-bin.jar¡¿µ¼Èë
2£¬´´½¨²âÊÔÁ¬½ÓÖ÷³ÌÐò
package mysqlConnection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class JdbcDemo {
public static void main(String[] args) {
......