java ×Ô¼ºÊµÏÖ ReadWriteLock £¨Ò»£©
¶àÏ̶߳Áдͬһ¸ö¶ÔÏóµÄÊý¾ÝÊǺÜÆÕ±éµÄ£¬Í¨³££¬Òª±ÜÃâ¶Áд³åÍ»£¬±ØÐë±£Ö¤ÈκÎʱºò½öÓÐÒ»¸öÏß³ÌÔÚдÈ룬ÓÐÏß³ÌÕýÔÚ¶ÁÈ¡µÄʱºò£¬Ð´Èë²Ù×÷¾Í±ØÐëµÈ´ý¡£¼òµ¥Ëµ£¬¾ÍÊÇÒª±ÜÃâ“д-д”³åÍ»ºÍ“¶Á-д”³åÍ»¡£µ«ÊÇͬʱ¶ÁÊÇÔÊÐíµÄ£¬ÒòΪ“¶Á-¶Á”²»³åÍ»£¬¶øÇҺܰ²È«¡£
ҪʵÏÖÒÔÉϵÄReadWriteLock£¬¼òµ¥µÄʹÓÃsynchronized¾Í²»ÐУ¬ÎÒÃDZØÐë×Ô¼ºÉè¼ÆÒ»¸öReadWriteLockÀ࣬ÔÚ¶Á֮ǰ£¬±ØÐëÏÈ»ñµÃ“¶ÁËø”£¬Ð´Ö®Ç°£¬±ØÐëÏÈ»ñµÃ“дËø”¡£¾ÙÀý˵Ã÷£º
DataHandler¶ÔÏó±£´æÁËÒ»¸ö¿É¶ÁдµÄchar[]Êý×飺
package com.crackj2ee.thread;
public class DataHandler {
// store
data:
private
char[] buffer = "AAAAAAAAAA".toCharArray();
private
char[] doRead() {
char[] ret = new char[buffer.length];
for(int i=0; i<buffer.length; i++) {
ret[i] = buffer[i];
sleep(3);
}
return ret;
}
private void
doWrite(char[] data) {
if(data!=null) {
buffer = new char[data.length];
for(int i=0; i<buffer.length; i++) {
buffer[i] = data[i];
sleep(10);
}
}
}
private void
sleep(int ms) {
try {
&nb
Ïà¹ØÎĵµ£º
GRASPģʽ:General Responsibility Assignment Software Patterns£ºÍ¨ÓÃÔðÈηÖÅäÈí¼þģʽ
ÀïÃæÖØÒªµÄ¸ÅÄîÊÇÔðÈΣ¬ÔðÈÎÊÇÀà¼äµÄÒ»ÖÖºÏÔ¼»òÊÇÒåÎñ£¬¿ÉÒÔϸ·ÖΪÁ½²¿·Ö£¬Óù«Ê½±íʾÈçÏ£º
ÔðÈÎ = ÖªµÀÔðÈÎ + ÐÐΪÔðÈΣ¨ÕâÀïÃæËƺõ´æÔÚ¸ÅÄîµÄÑ»·¶¨Ò壩
×¢£ºÓÃͨË׵Ļ°À´½²£¬ÔðÈξÍÊÇÒ»¸öÀàÖªµÀÒª×öʲô£¬²¢ÇÒÄܹ»×öʲô¡£
· ......
ÊʺϳõѧÕßÀí½â
1£¬testflex.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="init()"
minWidth="955 ......
1. ÑéÖ¤Âë(2)
dsnaValidateCode.jar
dsnaValidateCode_src.rar
ValidateCode.java ÑéÖ¤ÂëÉú³ÉÀà
Java´úÂë
package cn.dsna.util.images;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;   ......
package com.xiaobian;
public class BubbleSort {
//ðÅÝÅÅÐò
public static void bubbleSort(int[] data){
&n ......