Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JAVA and C++°æÐźÅÁ¿£¨PV²Ù×÷£©

import java.util.concurrent.Semaphore;
/**
* ³éÏóÈÎÎñ£¬¾ßÌåµÄÖ´ÐÐÈÎÎñ£¬¹éʵÏÖÀฺÔð
*
* @author Administrator
*
*/
public abstract class Task {
public abstract void run();
private Semaphore s;
private boolean hasExisted = false;
public void P(final Semaphore s) throws InterruptedException {
if (s == null) { // ÉêÇë¿ÕµÄÐźÅÁ¿
throw new InterruptedException("²»ÄÜΪ¿Õ");
}
if (hasExisted) {// ÒѾ­ÉêÇëÁËÒ»¸ö×ÊÔ´£¬»¹Ã»ÓÐÊÍ·Å
throw new InterruptedException("ÒѾ­Õ¼ÓÃÒ»¸ö×ÊÔ´");
}
s.acquire();// ×èÈû
this.s = s;
hasExisted = true;
}
public boolean V() {
if (!hasExisted) {
return false;// ûմÓÐ×ÊÔ´¾Í²»ÄÜ˵ÊÍ·ÅÁË
}
s.release();//ÊÍ·Å×ÊÔ´
hasExisted = false;
s = null;
return true;
}
}
import java.util.concurrent.Semaphore;
/**
* ÓÃÐźÅÁ¿ÊµÏÖ»¥³â
*
* @author Administrator
*
*/
public class Mutex extends Semaphore {
private static final long serialVersionUID = 1L;
public Mutex() {
super(1);//»¥³âÊÇ1
}
} import java.util.concurrent.Semaphore;
public class Test {
public static void main(String[] args) {
// final Semaphore s = new Semaphore(2);//ÐźÅÁ¿£¬Ö´Ðнá¹ûrun the task1 run the
// task2 run the task3
final Semaphore s = new Mutex();// »¥³â run the task1 run the task2 run
// the task3
new Thread() {
public void run() {
Task1 task2 = new Task1();
try {
task2.P(s);// ÉêÇë×ÊÔ´
task2.run();// Ö´ÐÐÈÎÎñ
task2.V();// ÊÍ·Å×ÊÔ´
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}.start();
new Thread() {
public void run() {
Task2 task2 = new Task2();
try {
task2.P(s);
task2.run();
task2.V();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}.start();
new Thread() {
public void run() {
Task3 task2 = new Task3();
try {
task2.P(s);
task2.run();
task2.V();
} catch (InterruptedException e)


Ïà¹ØÎĵµ£º

java ³£Óù¤¾ßÀà

DateTimeHelper ʱ¼ä×é¼þ
/**
 *
 */
package com.ibm08001.bbs.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 *
 */
public class DateTimeHelper {
        private static SimpleDateFormat FULL_SDF = new SimpleDateFormat ......

Java¶àÏ̱߳à³ÌÏê½â


Ò»¡¢Àí½â¶àÏß³Ì
    ¶àÏß³ÌÊÇÕâÑùÒ»ÖÖ»úÖÆ£¬ËüÔÊÐíÔÚ³ÌÐòÖв¢·¢Ö´Ðжà¸öÖ¸ÁîÁ÷£¬Ã¿¸öÖ¸ÁîÁ÷¶¼³ÆÎªÒ»¸öỊ̈߳¬±Ë´Ë¼ä»¥Ïà¶ÀÁ¢¡£Ïß³ÌÓÖ³ÆÎªÇáÁ¿¼¶½ø³Ì£¬ËüºÍ½ø³ÌÒ»ÑùÓµÓжÀÁ¢µÄÖ´ÐпØÖÆ£¬ÓɲÙ×÷ϵͳ¸ºÔðµ÷¶È£¬Çø±ðÔÚÓÚÏß³ÌûÓжÀÁ¢µÄ´æ´¢¿Õ¼ä£¬¶øÊǺÍËùÊô½ø³ÌÖÐµÄÆäËüÏ̹߳²ÏíÒ»¸ö´æ´¢¿Õ¼ä£¬ÕâʹµÃÏ̼߳äµÄ ......

JavaÓëÆäËûÓïÑԵĻ¥²Ù×÷ÐÔ

JavaÓëÆäËûÓïÑԵĻ¥²Ù×÷ÐÔ ÊÕ²Ø
Ŀǰ£¬ÎÒÃÇÏîÄ¿ÖÐÐèÒªÓõ½°ÑJava³ÌÐòǶÈëµ½.Net³ÌÐòÖеļ¼Êõ£¬ÎÒÃÇ×îºóËù²ÉÓõļ¼ÊõÊÇCodemesh¹«Ë¾µÄJuggerNET¡£ÕâÖÖÀàËÆµÄ¼¼ÊõºÜ¶à£¬±È½ÏÖªÃûµÄÖ÷ÒªÓÐintrinsyc¹«Ë¾µÄJIntegraÒÔ¼°IBMµÄJava COM bridge¡£
ÏîÄ¿½øÐе½ÏÖÔÚ£¬·¢ÏÖÁ˺ܶàÎÊÌ⣬Ö÷ÒªÓÐÈçϼ¸´óÀàÎÊÌ⣺
1¡¢µ¯³ö´°¿ÚÎÊÌâ
¶ÔÓ ......

air£¬java£¬DelphiµÝ¹é»ñµÃÎļþ¼Ð¼°Æä×ÓÎļþÐÅÏ¢

°ÑÒÔǰ×ö¹ýµÄÏîÄ¿×ܽáһϣ¡²Î¼Ó¹¤×÷ÒÔÀ´Ò»¹²ÓÃÈýÖÖ²»Í¬ÓïÑÔʵÏÖÁË»ñµÃÎļþ¼Ð¼°Æä×ÓÎļþÐÅÏ¢¡£ÎªÁË·½±ãÒÔºóʹÓÃ×ܽáÒ»ÏÂ
airʵÏÖ£º 
private function getfile(filelist:File):Array{  
  var list:Array = filelist.getDirectoryListing();
  var count:uint=list.length;
  ......

java¼ÓÃܺÍÊý×ÖÇ©Ãû1 ÏûÏ¢ÕªÒª

×î½ü³õ²½½Ó´¥ÁËÏÂJava¼ÓÃܺÍÊý×ÖÇ©ÃûµÄÏà¹ØÄÚÈÝ£¬ÎÒѧϰµÄ¹ý³Ì´ó¸Å·ÖÎå²½£º
1£©ÏûÏ¢ÕªÒª
2£©Ë½Ô¿¼ÓÃÜ
3£©¹«Ô¿¼ÓÃÜ
4£©Êý×ÖÇ©Ãû
5£©Êý×ÖÖ¤Êé
ÎÒ¸öÈËÈÏΪѧϰ±à³Ì×î¿ìµÄ·½·¨¾ÍÊÇʵ¼Ê½áºÏÀíÂÛ(¼´ÏÈʵ¼ÊÔÚÀíÂÛ)´úÂë×Ô¼ºÅÜÅÜ¿´£¬µ÷Ò»µ÷£¬·¢ÏÖÎÊÌâ»òÆæ¹ÖµÄµØ·½ÔÚÈ¥ÕÒÏà¹Ø×ÊÁϲé²é¡£±È´ÓÍ·µ½Î²¿´Ò»¶ÑÀíÂÛÈ»ºóÔÙÀíÂ۽Ạ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ