¶à´°¿ÚÒì²½ÊÛƱjava¾À´í
ÕâÊÇ·þÎñ´°¿ÚÀ࣬ģÄâËĸöÏß³ÌÒì²½ÔËÐÐ
public class TicketWindow {
public static void main(String args[]) {
Ticket ticket = new Ticket();
Thread w1 = new Thread(ticket, "1ºÅÊÛƱ´°¿Ú");
Thread w2 = new Thread(ticket, "2ºÅÊÛƱ´°¿Ú");
Thread w3 = new Thread(ticket, "3ºÅÊÛƱ´°¿Ú");
Thread w4 = new Thread(ticket, "4ºÅÊÛƱ´°¿Ú");
w1.setPriority(Thread.NORM_PRIORITY);
w2.setPriority(Thread.NORM_PRIORITY);
w3.setPriority(Thread.NORM_PRIORITY);
w4.setPriority(Thread.NORM_PRIORITY);
w1.start();
w2.start();
w3.start();
w4.start();
}
}
ÒÔÏÂÊÇticketÀ࣬¿ØÖÆ´°¿Ú³öƱµÄÂß¼
public class Ticket implements Runnable {
private int ticketNumber = 1;
public void sellTicket() {
while (ticketNumber++ < 100) {
synchronized (this) {
System.out.println(Thread.currentThread().getName() + "ÕýÔÚÊÛ³öµÚ"
+ ticketNumber + "ÕÅƱ");
}
}
}
public void run() {
sellTicket();
}
}
ÔËÐÐÀàTicketWindow£¬
²¿·Ö½á¹ûÈçÏ£º
1ºÅÊÛƱ´°¿ÚÕýÔÚÊÛ³öµÚ2ÕÅƱ
2ºÅÊÛƱ´°¿ÚÕýÔÚÊÛ³öµÚ5ÕÅƱ
4ºÅÊÛƱ´°¿ÚÕýÔÚÊÛ³öµÚ6ÕÅƱ
3ºÅÊÛƱ´°¿ÚÕýÔÚÊÛ³öµÚ7ÕÅƱ
3ºÅÊÛƱ´°¿ÚÕýÔÚÊÛ³öµÚ8ÕÅƱ
3ºÅÊÛƱ´°¿ÚÕýÔÚÊÛ³öµÚ9ÕÅƱ
2ºÅÊÛƱ´°¿ÚÕýÔÚÊÛ³öµÚ11ÕÅƱ
4ºÅÊÛƱ´°¿ÚÕýÔÚÊÛ³öµÚ11ÕÅƱ
¡£¡£¡£
2ºÅÊÛƱ´°¿ÚÕýÔÚÊÛ³öµÚ101ÕÅƱ
1ºÅÊÛƱ´°¿ÚÕýÔÚÊÛ³öµÚ102ÕÅƱ
4ºÅÊÛƱ´°¿ÚÕýÔÚÊÛ³öµÚ103ÕÅƱ
°´ÔËÐÐÇé¿öÀ´¿´£¬´æÔÚÈý¸öÎÊÌ⣺
1.³öƱ²»Á¬Ðø----ƱºÅÓмä¶Ï
2.ƱºÅÖظ´--²»Í¬´°¿ÚÊÛ³öÖØͬһƱºÅ
3.¶àÂôƱ--Âô³öƱÊý³¬¹ý100
ÒÔÏÂÊÇÕýÈ·µÄ´úÂ룺
public class Ticket implements Runnable {
private int ticketNumber = 1;
public void sellTicket() {
while (ticketNumber < 100) {//ƱºÅµÝÔö²Ù×÷Ó¦ÊôÓÚÁÙ½çÇø£¬Ðë·ÅÔÚsynchronizedÓï¾ä¿éÄÚ /
synchronized (this) {
if (ticketN
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
¾³£¿´µ½Ðí¶àÈËÎÊÈçºÎÅäÖÃJDKºÍJSP£¬ÏÖÔÚÎÒ°Ñ·½·¨×ܽáÏ£¬Ï£Íû¶Ô´ó¼ÒÓÐËù°ïÖú¡£
µÚÒ»²½£ºÏÂÔØjdkºÍtomcat
µÚ¶þ²½£º°²×°ºÍÅäÖÃÄãµÄjdkºÍtomcat£ºÖ´ÐÐjdkºÍtomcatµÄ°²×°³ÌÐò£¬È»ºóÉèÖð´ÕÕ·¾¶½øÐа²×°¼´¿É¡£
1.°²×°j2sdkÒÔºó£¬ÐèÒªÅäÖÃһϻ·¾³±äÁ¿£¬ÔÚÎҵĵçÄÔ->ÊôÐÔ->¸ß¼¶->»·¾³±äÁ¿->ϵͳ±äÁ¿ÖÐÌí¼Ó ......
Õ⼸ÌìÒ»Ö±ÔÚ¸ã¹ØÓÚÓÅÏȼ¶¶ÓÁеÄʵÏÖ,ÒòΪҪ¿¼Âǵ½Ï̵߳ݲȫ,ËùÒÔPriorityQueue¾Í²»ÊÊÓÃÁË¡£Ò»¸ö·Ç³£¼òµ¥µÄʵÏÖ·½
·¨£¬ÄǾÍÊÇ°ÑÓÅÏȼ¶±È½ÏºÃµÄ²åÈëÒ»¸ö¶ÓÁУ¬ÓÅÏȼ¶µÍµÄ²åÈëÁíÒ»¸ö¶ÓÁУ¬È¡ÊýµÄʱºòÏÈÔÚÓÅÏȼ¶¸ßµÄ¶ÓÁÐÉÏÈ¡Êý¡£ÕâÓиöȱµã¾ÍÊÇÈç¹ûÓÅÏȼ¶±ðÔ½¶àµÄ»°£¬¶ÓÁ ......