1. SerialBean
SerialBeanÊDZ¾Àà¿âÓëÆäËûÓ¦ÓóÌÐòµÄ½Ó¿Ú¡£¸ÃÀà¿âÖж¨ÒåÁËSerialBeanµÄ¹¹Ôì·½·¨ÒÔ¼°³õʼ»¯´®¿Ú£¬´Ó´®¿Ú¶ÁÈ¡Êý¾Ý£¬Íù´®¿ÚдÈëÊý¾ÝÒÔ¼°¹Ø±Õ´®¿ÚµÄº¯Êý¡£¾ßÌå½éÉÜÈçÏ£º
public SerialBean(int PortID)
±¾º¯Êý¹¹ÔìÒ»¸öÖ¸ÏòÌض¨´®¿ÚµÄSerialBean£¬¸Ã´®¿ÚÓɲÎÊýPortIDËùÖ¸¶¨¡£PortID = 1 ±íʾCOM1£¬PortID = 2 ±íʾCOM2£¬ÓÉ´ËÀàÍÆ¡£
public int Initialize()
±¾º¯Êý³õʼ»¯ËùÖ¸¶¨µÄ´®¿Ú²¢·µ»Ø³õʼ»¯½á¹û¡£Èç¹û³õʼ»¯³É¹¦·µ»Ø1£¬·ñÔò·µ»Ø-1¡£³õʼ»¯µÄ½á¹ûÊǸô®¿Ú±»SerialBean¶ÀÕ¼ÐÔʹÓã¬Æä²ÎÊý±»ÉèÖÃΪ9600, N, 8, 1¡£Èç¹û´®¿Ú±»³É¹¦³õʼ»¯£¬Ôò´ò¿ªÒ»¸ö½ø³Ì¶ÁÈ¡´Ó´®¿Ú´«ÈëµÄÊý¾Ý²¢½«Æä±£´æÔÚ»º³åÇøÖС£
public String ReadPort(int Length)
±¾º¯Êý´Ó´®¿Ú(»º³åÇø)ÖжÁÈ¡Ö¸¶¨³¤¶ÈµÄÒ»¸ö×Ö·û´®¡£²ÎÊýLengthÖ¸¶¨Ëù·µ»Ø×Ö·û´®µÄ³¤¶È¡£
public void WritePort(String Msg)
±¾º¯ÊýÏò´®¿Ú·¢ËÍÒ»¸ö×Ö·û´®¡£²ÎÊýMsgÊÇÐèÒª·¢Ë͵Ä×Ö·û´®¡£
public void ClosePort()
±¾º¯ÊýÍ£Ö¹´®¿Ú¼ì²â½ø³Ì²¢¹Ø±Õ´®¿Ú¡£
package serial;
import java.io.*;
import java.util.*;
import javax.comm.*;
/**
*
* This bean provides some ......
¿´µ½Ô°×ÓµÄͬÁÅÃÇдµÄ¡¶¿çƽ̨¡·ÏµÁÐÖ®ºóÕæµÄÊÇÈÈѪ·ÐÌÚ£¬ÓÐЩ»°²»µÃ²»Ëµ£¬²»Äܲ»Ëµ¡£ÎÒÒª½ÒµôJavaÕâÒ»²ã²ãÃÀÀöµÄ“»Æ¤”,Èôó¼Ò¿´¿´»Æ¤Ö®ÏÂÊÇʲô£¿ÎÒÃÇ¿´µ½µÄ¶¼ÊÇһЩʲô£¿ÎÒ±¾È˲¢²»ÊÇÒ»¶¨µÃÍƼö´ó¼ÒÓÃ.NETƽ̨£¬µ«ÊÇÎÒ¾ÍÊÇ¿´²»¹ÜÓÐЩÈËÎóµ¼³õѧÕߣ¬ÏòËûÃÇ´«µ¼Ê²Ã´¶¼µÃÓÃJavaд£¬Ê²Ã´¶¼ÊÇJava×îÅ£B¡£ÎÒÈÏΪӦ¸Ã¸ù¾ÝÏîÄ¿µÄÒªÇó¶øÑ¡Ôñƽ̨Ó뿪·¢ÓïÑÔ£¬±ÈÈç×öC/S¿ª·¢Ñ¡Ôñ.NET¾ø¶ÔÊÇÃ÷Öǵģ¬Èç¹ûÄúÐèÒª¿çƽ̨Äú¿ÉÒÔÑ¡ÓÃQTÖ®ÀàµÄ£¬¸ÉÂïÆ«Æ«ÓÃSwingÄÄ£¿Ò²ÐíÓÃSWingÄÜÏԵóöËû±È±ðÈËÅ££¿×öWEB¿ª·¢Ñ¡ÔñPHPÓ¦¸ÃÒ²ÊÇÃ÷ÖǵÄÑ¡Ôñ£¬¾ý²»¼ûÊÀ½çÉÏÁ½¸öÍøÕ¾Ö®Ò»FaceBook¾ÍÊÇÓÃPHPµÄÂ𣿲ÉÓÃPHP·½±ã¿ì½Ý¿ª·¢Ëٶȿ죬²¿Ê𷽱㡣ÓеÄʱºòÎÒ¶¼ºÍ±ðÈË˵ASP.NETºÍPHPÕâ¸öСÐֵܱÈÆðÀ´Ò²²î²»ÉÙÄÄ£¬µ«ÄãÓÃJavaÀ´¿ª·¢£¿ºÇºÇºÇ¡£¡£ÄãÄܳԶàÉÙ¿àÎÒÏëÖ»ÓÐÄã×ÔÒÑÄÜÖªµÀ°É¡£ºÃÁË·Ï»°ÉÙ˵£¬ÎÒÃÇÀ´½Ò“»Æ¤”°É
»Æ¤Ö®Ò»£ºJavaµÄµÍ³É±¾
JavaµÄµÍ³É±¾ÄѵÀÕæµÄºÜµÍÂð£¿ÊÀ½çûÓÐÎÚÍа´ó¼Ò¶¼Òª³Ô·¹ÄÄ£¬±ð×öÃÎÁË£¡
Ê×ÏÈÎÒÃÇÏÈÌÖÂÛËüµÄ·þÎñÆ÷£¬ºÜ¶àÈË¿ÉÄܺܿì¾Í¸ ......
1. ¸ÅÄ ÐòÁл¯¾ÍÊǰѶÔÏó±ä³É¶ÔÏóÁ÷£¨È·ÇÐ˵ÊǰѶÔÏóµÄÊôÐÔдÈëÁ÷£©£¬Èç¹ûÐèÒª½ø¶ø¿ÉÒ԰ѶÔÏóÁ÷´æ³É¶þ½øÖÆÎļþ£»
2. Ä¿µÄ£º ÐòÁл¯µÄÄ¿µÄÊÇΪÁË·½±ãÓÀ¾Ã´æ´¢»òÕßÍøÂç´«Ê䣻
3. ÈçºÎʵÏÖ£º ½«ÀàʵÏÖSerializable½Ó¿Ú¼´¿É£¬ÎÞ±ØÐëʵÏֵķ½·¨£¬ÊµÏָýӿÚÖ»ÊÇΪÁ˱êʶ¸ÃÀà¿É±»ÐòÁл¯£»
4. £¨×ª£©ÆäËûÐèÒªÖªµÀµÄ£º
Ò»¡¢ÔÚ¿ÉÐòÁл¯ÀàÖÐÒª¶¨ÒåserialVersionUID£»
¶þ¡¢±êʶ²»ÐèÒªÐòÁл¯µÄ³ÉÔ±£¬¿ÉÒÔʹÓÃtransient¹Ø¼ü×Ö£»
Èý¡¢ÓÃÀ´±»¼Ì³ÐµÄÀ࣬¾¡Á¿²»ÊµÏÖSerializable£¬ÓÃÀ´±»ÊµÏÖµÄinterfaceÒ²²»Òª¼Ì³ÐSerializable¡£Èç¹û¸¸À಻ʵÏÖSerializable½Ó¿Ú£¬×ÓÀàºÜÄÑʵÏÖËü£¬ÌرðÊǶÔÓÚ¸¸ÀàûÓÐÎ޲ι¹Ô캯ÊýµÄʱºò¡£ËùÒÔ£¬²»ÊµÏÖSerializable½Ó¿ÚÇҿɱ»¼Ì³ÐµÄÀ࣬ÇÒ×ÓÀàÐëÐòÁл¯ÊÇ£¬ÐèÒªÌṩһ¸öÎÞ²ÎÊý¹¹Ô캯Êý¡£ ......
ÖÚËùÖÜÖª£¬ÔÚJava¶àÏ̱߳à³ÌÖУ¬Ò»¸ö·Ç³£ÖØÒªµÄ·½Ãæ¾ÍÊÇÏ̵߳Äͬ²½ÎÊÌâ¡£
¹ØÓÚÏ̵߳Äͬ²½£¬Ò»°ãÓÐÒÔϽâ¾ö·½·¨£º
1. ÔÚÐèҪͬ²½µÄ·½·¨µÄ·½·¨Ç©ÃûÖмÓÈësynchronized¹Ø¼ü×Ö¡£
תÔØ×¢Ã÷³ö´¦£ºhttp://x- spirit.javaeye.com/¡¢http: //www.blogjava.net/zhangwei217245/
2. ʹÓÃsynchronized¿é¶ÔÐèÒª½øÐÐͬ²½µÄ´úÂë¶Î½øÐÐͬ²½¡£
תÔØ×¢Ã÷³ö´¦£ºhttp://x- spirit.javaeye.com/¡¢http: //www.blogjava.net/zhangwei217245/
3. ʹÓÃJDK 5ÖÐÌṩµÄjava.util.concurrent.lock°üÖеÄLock¶ÔÏó¡£
תÔØ×¢Ã÷³ö´¦£ºhttp://x- spirit.javaeye.com/¡¢http: //www.blogjava.net/zhangwei217245/
ÁíÍ⣬ΪÁ˽â¾ö¶à¸öÏ̶߳Ôͬһ±äÁ¿½øÐзÃÎÊʱ¿ÉÄÜ·¢ÉúµÄ°²È«ÐÔÎÊÌ⣬ÎÒÃDz»½ö¿ÉÒÔ²ÉÓÃͬ²½»úÖÆ£¬¸ü¿ÉÒÔͨ¹ýJDK 1.2ÖмÓÈëµÄThreadLocalÀ´±£Ö¤¸üºÃµÄ²¢·¢ÐÔ¡£
±¾ÆªÖУ¬½«ÏêϸµÄÌÖÂÛJava¶àÏß³Ìͬ²½»úÖÆ£¬²¢¶ÔThreadLocal×ö³ö̽ÌÖ¡£
´óÖµÄĿ¼½á¹¹ÈçÏ£º
Ò»¡¢Ï̵߳ÄÏÈÀ´ºóµ½——ÎÊÌâµÄÌá³ö£ºÎªÊ²Ã´ÒªÓжàÏß³Ìͬ²½£¿Java¶àÏß³Ìͬ²½µÄ»úÖÆÊÇʲô£¿
¶þ¡¢¸øÎÒÒ»°ÑËø£¬ÎÒÄÜ´´ÔìÒ»¸ö¹æ¾Ø——´«Í³µÄ¶àÏß³Ìͬ²½±à³Ì·½·¨ÓÐÄÄЩ£¿ËûÃÇÓкÎÒìͬ£¿
Èý¡¢LockÀ´ÁË£¬´ó¼Ò¶¼Èÿª&m ......
import java.util.ArrayList;
import java.util.HashMap;
public class Client {
/**
* @param args
*/
public static void main(String[] args) {
test1();
System.out.println("==================================");
test2();
}
public static void test1(){
ParentObj po = new ParentObj();
ArrayList list = new ArrayList();
po.doWork(list);
po = new ChildObj();
po.doWork(list);
ChildObj co = new ChildObj();
co.doWork(list);
}
public static void test2(){
ParentObj po = new ParentObj();
HashMap map = new HashMap();
po.doSport(map);
po = new ChildObj();
po.doSport(map);
ChildObj co = new ChildObj();
co.doSport(map);
}
}
imp ......
import java.util.Timer;
import java.util.TimerTask;
public class EggTimer {
private final Timer timer = new Timer();
private final int minutes;
public EggTimer(int minutes) {
this.minutes = minutes;
}
public void start() {
timer.schedule(new TimerTask() {
public void run() {
playSound();
timer.cancel();
  ......
×ܼǼÊý:6386; ×ÜÒ³Êý:1065; ÿҳ6 Ìõ;
Ê×Ò³ ÉÏÒ»Ò³ [1] [2] [3] [4] 5
[6] [7] [8] [9] [10] ÏÂÒ»Ò³ βҳ