锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
]]>
However, Java provides a more elegant solution: the volatile keyword. If a variable is marked as volatile, every time the variable is used it must be read from main memory. Similarly, every time the variable is written, the value must be stored in main memory. Since these operations are atomic, we can avoid the race condition in our example by marking our done flag as volatile.
聽
鍦╰ij涓篃鏈夎榪?/p>
聽Thinking 聽 in聽聽 java聽聽 鐨?聽 13.7 聽 鑼冧緥 聽 CanStop 聽 閲岄潰鏈変唬鐮?聽
聽 //Must 聽 be 聽 volatile: 聽
聽 private 聽 volatile 聽 boolean 聽 stop 聽 = 聽 false; 聽
聽 榪欓噷boolean綾誨瀷搴旇灝卞凡緇忔槸鍘熷瓙鎿嶄綔浜嗭紝涓嶉渶瑕佸啀淇濊瘉浜嗐?聽
聽 聽
聽 涔﹂噷璇?聽 stop鏍囧織蹇呴』鏄?b style="COLOR: black; BACKGROUND-COLOR: #ffff66">volatile鐨勶紝浠ヤ究run()鏂規(guī)硶鑲畾鐪嬪埌浠栵紙鍚﹀垯鐨勮瘽錛岃繖涓煎彲鑳芥湰鍦扮紦瀛? 聽
聽 聽
聽 鎴戠寽鎯?聽 volatile琛ㄧず榪欎釜鍊煎彲鑳借鍒殑綰跨▼鏀瑰彉錛屾墍浠ヨ鏍囧織涓?b style="COLOR: black; BACKGROUND-COLOR: #ffff66">volatile鐨勫彉閲忥紝姣忔閮芥槸浠庡瓨鍌ㄥ尯涓鍙栧彉閲忓搴旂殑鍊鹼紝鑰屼笉鏄湪璇ョ嚎紼嬩腑鏈湴緙撳瓨鐨勫箋傚洜涓烘湰鍦扮紦瀛樼殑鍊間笉鑳藉強(qiáng)鏃跺弽鏄犲叾浠栫嚎紼嬪榪欎釜鍙橀噺鐨勫獎(jiǎng)鍝嶃偮犅犅?br />聽
鍦ㄧ嚎紼嬩腑 璇ュ叧閿瓧榪樻槸浼?xì)鐢ㄥ埌鐨?.
鍦板潃錛?a >http://tap.javalobby.org/javaee5.mp3
姝岃瘝錛?br />Ladies and gentlemen, this is Java EE 5!
One, two, three, four, five
There's a technology I use day and night
For my application with a web frontend
They told me to use .Net
But I really don麓t wanna
So many bugs I fixed last week.
My code is neat and talk is a cheap
I like Glassfish, JSF, persistence API
And as I continue you know they麓re gettin麓 sweeter
So what can I do I really beg you my Lord
To me codin' it麓s just like a sport
All the bad code from the past, let me dump it
Please set in the trumpet
A little bit of injection in my life
A little bit of persistence by my side
A little bit of NetBeans is all I need
A little bit of EJB's what I see
A little bit of standards in the sun
A little bit of XML all night long
A little bit web services here I am
A little bit of code makes me real man
This is Java EE 5!
Jump up and down and move your code around
Shake your head to the sound bury bad code under ground
Move one step left and one step right
One to the front and one to the side
Refactor it once and refactor it twice
If it looks like this you're doin麓 it right
A little bit of injection in my life
A little bit of persistence by my side
A little bit of NetBeans is all I need
A little bit of EJB's is what I see
A little bit of standards in the sun
A little bit of XML all night long
A little bit web services here I am
A little bit of code makes me real man
This is Java EE 5!
榪樹笉閿欏摝.
from csdn
Francois Orsini has announced that Apache Derby has become bundled with the latest 1.6 JDK. "...yes it has become a reality! - It is a very exciting event indeed to have an Open Source Java Database System bundled into Sun's *latest* 1.6 JDK (Mustang build 88 to be more precised), and at no cost."
鐩稿叧榪炴帴:
瀛︿範(fàn)浣跨敤Java DataBase (Derby) -- 宓屽叆寮忔暟鎹簱
鍦╠erby(Java DB) 涓搷浣?clob 鍜?blob
鍏充簬鍏抽棴Java DB(Derby)鏃舵姏鍑哄紓甯哥殑闂
鐢ㄦ埛璁ㄨ鍖? http://www.hexiao.cn/bbs/thread.php?fid=9
澶у閮界煡閬撳紑鍙慡wing紼嬪簭鏈変笁澶ч毦鐐?
甯冨眬璁劇疆,浜嬩歡澶勭悊,鍜屾暟鎹粦瀹? 浣跨敤netbean涓殑鏂扮殑甯冨眬綆$悊鍣ㄥ凡緇忚В鍐充簡絎竴涓棶棰? 閭d箞鍚庨潰涓や釜鍛?
Breezy 灝辨槸鐢ㄦ潵綆鍖栧悗闈袱涓棶棰樿屾帹鍑虹殑.
涓嬮潰鎴戜滑鍏堟潵鐪嬬湅涓涓畝鍗曠殑渚嬪瓙:
package test;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import net.sf.breezy.event.EventInstaller;
import net.sf.breezy.event.annotations.ActionPerformed;
import net.sf.breezy.event.annotations.DefAction;
@SuppressWarnings("serial")
public class TestBreezy extends JFrame {
聽 聽 聽
聽 聽 聽private JButton button = new JButton("Test Breezy!");
聽 聽 聽
聽 聽 聽public TestBreezy() {
聽 聽 聽 聽 聽 聽this.setLayout(new BorderLayout());
聽 聽 聽 聽 聽 聽this.add(button,BorderLayout.CENTER);
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽// 鐢ㄦ潵澶勭悊鎵鏈夌殑Breezy鐨凙nnotations
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 EventInstaller.processEventAnnotation(this);
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽this.setSize(400, 300);
聽 聽 聽 聽 聽 聽this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽EventInstaller.setAction(button, "action");
聽 聽 聽}
聽 聽 聽
聽 // button鐨勪簨浠跺搷搴旀柟娉?br />聽 聽 聽@ActionPerformed("button")
聽 聽 聽public void myButtonAction() {
聽 聽 聽 聽 聽 System.out.println("God, this is terrific!");//璁劇疆鍙﹀涓涓簨浠?br />聽 聽 聽}
聽 聽 聽
// 浣跨敤id娉ㄥ唽鍙﹀涓涓簨浠跺搷搴旀柟娉?br />聽 聽 聽@DefAction(id="action", name="Button")
聽 聽 聽void action(ActionEvent e) {
聽 聽 聽 聽 聽 聽System.out.println(e + ":" + e);
聽 聽 聽}
聽 聽 聽/**
聽 聽 聽 * @param args
聽 聽 聽 */
聽 聽 聽public static void main(String[] args) {
聽 聽 聽 聽 聽 聽// TODO Auto-generated method stub
聽 聽 聽 聽 聽 聽JFrame frame = new TestBreezy();
聽 聽 聽 聽 聽 聽frame.setVisible(true);
聽 聽 聽}
}
鎬庝箞鏍? 鐪嬭搗鏉ヤ笉閿欏惂.
鐜板湪Breezy鍑犱箮鏀寔鎵鏈夌殑Swing EventListeners. 璇︾粏鎯呭喌璇鋒煡鐪嬬被net.sf.breezy.event.annotations.*
褰撶劧浜? 浣滀負(fù)涓涓紭縐鐨勬鏋?榪樿鏈夊彲鎵╁睍鎬?鍦˙reezy涓紑鍙戣呰繕鍙互鑷畾涔夎嚜宸辯殑浜嬩歡鍝嶅簲Annotation 鏉ュ疄鐜拌嚜宸辯殑鍔熻兘. 璇︾粏鎯呭喌璇鋒煡鐪婣PI.
鏁版嵁緇戝畾闂涓昏 灝辨槸 JTable 鍜孞Tree鐨勯棶棰?
浣跨敤Breezy鏉ュ鐞嗚闂,鏈夌偣綾諱技浜嶩ibernate涓殑xml鏄犲皠鏁版嵁搴撳睘鎬у瓧孌靛樊涓嶅. 鍙互寰堟柟渚跨殑鏄犲皠.
璇風(fēng)湅涓嬮潰鐨勪緥瀛? 鍜孊reezy鏂囨。:
package test;
import java.util.Date;
public class Name {
聽 聽 聽private String name = "Starwhisperer";
聽 聽 聽private Date time = new Date();
聽 聽 聽public String getName() {
聽 聽 聽 聽 聽 聽return name;
聽 聽 聽}
聽 聽 聽public void setName(String name) {
聽 聽 聽 聽 聽 聽this.name = name;
聽 聽 聽}
聽 聽 聽public Date getTime() {
聽 聽 聽 聽 聽 聽return time;
聽 聽 聽}
聽 聽 聽public void setTime(Date time) {
聽 聽 聽 聽 聽 聽this.time = time;
聽 聽 聽}
}
User.java
package test;
import java.util.Date;
import net.sf.breezy.datatable.TableField;
public class User {
聽 聽 聽@TableField(head = "鍚嶇О", editable = false)
聽 聽 聽private String name;
聽 聽 聽@TableField(head = "騫撮緞", editable = false, type = "number")
聽 聽 聽private int age;
聽 聽 聽@TableField(head = "闃佃惀", type = "boolean", editable = false)
聽 聽 聽private boolean light;
聽 聽 聽@TableField(head = "鏃墮棿", type = "time", pattern = "yyyy/MM/dd")
聽 聽 聽private Date date = new Date();
聽 聽 聽@TableField(head = "鍚嶇О", property = "name", type="string")
聽 聽 聽private Name nameBean = new Name();
聽 聽 聽public Name getNameBean() {
聽 聽 聽 聽 聽 聽return nameBean;
聽 聽 聽}
聽 聽 聽public void setNameBean(Name nameBean) {
聽 聽 聽 聽 聽 聽this.nameBean = nameBean;
聽 聽 聽}
聽 聽 聽public boolean isLight() {
聽 聽 聽 聽 聽 聽return light;
聽 聽 聽}
聽 聽 聽public void setLight(boolean light) {
聽 聽 聽 聽 聽 聽this.light = light;
聽 聽 聽}
聽 聽 聽public int getAge() {
聽 聽 聽 聽 聽 聽return age;
聽 聽 聽}
聽 聽 聽public void setAge(int age) {
聽 聽 聽 聽 聽 聽this.age = age;
聽 聽 聽}
聽 聽 聽public String getName() {
聽 聽 聽 聽 聽 聽return name;
聽 聽 聽}
聽 聽 聽public void setName(String name) {
聽 聽 聽 聽 聽 聽this.name = name;
聽 聽 聽}
聽 聽 聽public Date getDate() {
聽 聽 聽 聽 聽 聽return date;
聽 聽 聽}
聽 聽 聽public void setDate(Date date) {
聽 聽 聽 聽 聽 聽this.date = date;
聽 聽 聽}
}
DataTableTest .java
package test;
import java.awt.BorderLayout;
import java.util.LinkedList;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import net.sf.breezy.datatable.DataTable;
import net.sf.breezy.datatable.DataTableScrollPane;
public class DataTableTest {
聽 聽 聽private JFrame mainFrm = new JFrame();
聽 聽 聽
聽 聽 聽protected void setUp() { 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽mainFrm.setSize(100, 600);
聽 聽 聽 聽 聽 聽mainFrm.setLocationRelativeTo(null);
聽 聽 聽 聽 聽 聽mainFrm.setLayout(new BorderLayout());
聽 聽 聽 聽 聽 聽mainFrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
聽 聽 聽}
聽 聽 聽
聽 聽 聽public static void main(String[] args) {
聽 聽 聽 聽 聽 聽DataTableTest test = new DataTableTest();
聽 聽 聽 聽 聽 聽test.setUp();
聽 聽 聽 聽 聽 聽test.testTable();
聽 聽 聽}
聽 聽 聽
聽 聽 聽public void testTable() { 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽java.util.List list = new LinkedList();
聽 聽 聽 聽 聽 聽for(int i = 0; i < 120; i ++) {
聽 聽 聽 聽 聽 聽 聽 聽 聽User u = new User();
聽 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 聽u.setAge(33);
聽 聽 聽 聽 聽 聽 聽 聽 聽u.setName("Cain " + i);
聽 聽 聽 聽 聽 聽 聽 聽 聽list.add(u);
聽 聽 聽 聽 聽 聽}
聽 聽 聽 聽 聽 聽DataTableScrollPane<User> pane = DataTable.getEntityTablePane(list, User.class);
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽mainFrm.add(pane, BorderLayout.CENTER); 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽mainFrm.setVisible(true);
聽 聽 聽}
}
鏄犲皠鏂囦歡:datatable-mappings.xml
<?xml version="1.0"?>
<class-mapping>
聽 聽 聽<class name="test.User">
聽 聽 聽 聽 聽 聽<property name="age" head="騫撮緞" />
聽 聽 聽 聽 聽 聽<property name="light" head="鍏夎姃" type="boolean" editable="true"/>
聽 聽 聽 聽 聽 聽<property name="nameBean" property="time" head="濮撳悕" pattern="yyyy/mm/dd" type="time"/>
聽 聽 聽 聽 聽 聽<property name="date" head="Date"/>
聽 聽 聽 聽 聽 聽<property name="name" head="Name"/>
聽 聽 聽</class>
</class-mapping>
涔熸槸寰堢畝鍗曠殑鍚? 鍏充簬JTree鐨勫簲鐢ㄤ篃鏄緢綆鍗曠殑鍝? 璇︾粏鎯呭喌璇鋒煡鐪嬬敤鎴鋒枃妗?
鏇村淇℃伅璇峰叧娉?鐢ㄦ埛浜ゆ祦璁哄潧: http://www.hexiao.cn/bbs/thread.php?fid=9聽
Google Web Toolkit (GWT) is a Java software development framework that makes writing AJAX applications like Google Maps and Gmail easy for developers who don't speak browser quirks as a second language. Writing dynamic web applications today is a tedious and error-prone process; you spend 90% of your time working around subtle incompatabilities between web browsers and platforms, and JavaScript's lack of modularity makes sharing, testing, and reusing AJAX components difficult and fragile.
GWT lets you avoid many of these headaches while offering your users the same dynamic, standards-compliant experience. You write your front end in the Java programming language, and the GWT compiler converts your Java classes to browser-compliant JavaScript and HTML.
浼撮殢鐫Java EE 5 SDK(涓嬭澆) 鐨?/strong>鍙戝竷,鏈鏂扮殑 Pet Store (鏈鍒濈増) 寮濮嬪叏闈㈠惎鐢?Web 2.0 鎶鏈?
Sean 鍜?Geertjan 閮芥浘緇忓姝ゆ湁鎵浠嬬粛銆?Alexis 榪樺埗浣滀簡涓涓煭鐗囧悜鎮(zhèn)ㄥ睍紺烘庢牱鍦?NetBeans 涓惎鍔?br />聽
Pet Store錛?澶у瀷 鎴?灝忓瀷錛夈?