??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.
(tng)
在tij中也有讲q?/p>
(tng)Thinking (tng) in (tng) (tng) java (tng) (tng) ? (tng) 13.7 (tng) 范例 (tng) CanStop (tng) 里面有代? (tng)
(tng) //Must (tng) be (tng) volatile: (tng)
(tng) private (tng) volatile (tng) boolean (tng) stop (tng) = (tng) false; (tng)
(tng) q里booleancd应该已l是原子操作?jin),不需要再保证?jin)? (tng)
(tng) (tng)
(tng) 书里? (tng) stop标志必须?b style="COLOR: black; BACKGROUND-COLOR: #ffff66">volatile的,以便run()Ҏ(gu)肯定看到他(否则的话Q这个值可能本地缓? (tng)
(tng) (tng)
(tng) 我猜? (tng) volatile表示q个值可能被别的U程改变Q所以被标志?b style="COLOR: black; BACKGROUND-COLOR: #ffff66">volatile的变量,每次都是从存储区中读取变量对应的|而不是在该线E中本地~存的倹{因为本地缓存的g能及(qing)时反映其他线E对q个变量的媄(jing)响。?tng) (tng)?br /> (tng)
在线E中 该关键字q是?x)用到?.
地址Q?a >http://tap.javalobby.org/javaee5.mp3
歌词Q?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!
q(sh)错哦.
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."
相关q接:
学习(fn)使用Java DataBase (Derby) -- 嵌入式数据库
在derby(Java DB) 中操?clob ?blob
关于关闭Java DB(Derby)时抛出异常的问题
用户讨论? http://www.hexiao.cn/bbs/thread.php?fid=9
大家都知道开发SwingE序有三大难?
布局讄,事g处理,和数据绑? 使用netbean中的新的布局理器已l解决了(jin)W一个问? 那么后面两个?
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 {
(tng) (tng) (tng)
(tng) (tng) (tng)private JButton button = new JButton("Test Breezy!");
(tng) (tng) (tng)
(tng) (tng) (tng)public TestBreezy() {
(tng) (tng) (tng) (tng) (tng) (tng)this.setLayout(new BorderLayout());
(tng) (tng) (tng) (tng) (tng) (tng)this.add(button,BorderLayout.CENTER);
(tng) (tng) (tng) (tng) (tng) (tng)
(tng) (tng) (tng) (tng) (tng) (tng)// 用来处理所有的Breezy的Annotations
(tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) EventInstaller.processEventAnnotation(this);
(tng) (tng) (tng) (tng) (tng) (tng)
(tng) (tng) (tng) (tng) (tng) (tng)this.setSize(400, 300);
(tng) (tng) (tng) (tng) (tng) (tng)this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
(tng) (tng) (tng) (tng) (tng) (tng)
(tng) (tng) (tng) (tng) (tng) (tng)EventInstaller.setAction(button, "action");
(tng) (tng) (tng)}
(tng) (tng) (tng)
(tng) // button的事件响应方?br /> (tng) (tng) (tng)@ActionPerformed("button")
(tng) (tng) (tng)public void myButtonAction() {
(tng) (tng) (tng) (tng) (tng) System.out.println("God, this is terrific!");//讄另外一个事?br /> (tng) (tng) (tng)}
(tng) (tng) (tng)
// 使用id注册另外一个事件响应方?br /> (tng) (tng) (tng)@DefAction(id="action", name="Button")
(tng) (tng) (tng)void action(ActionEvent e) {
(tng) (tng) (tng) (tng) (tng) (tng)System.out.println(e + ":" + e);
(tng) (tng) (tng)}
(tng) (tng) (tng)/**
(tng) (tng) (tng) * @param args
(tng) (tng) (tng) */
(tng) (tng) (tng)public static void main(String[] args) {
(tng) (tng) (tng) (tng) (tng) (tng)// TODO Auto-generated method stub
(tng) (tng) (tng) (tng) (tng) (tng)JFrame frame = new TestBreezy();
(tng) (tng) (tng) (tng) (tng) (tng)frame.setVisible(true);
(tng) (tng) (tng)}
}
怎么? 看v来不错吧.
现在Breezy几乎支持所有的Swing EventListeners. 详细情况h看类net.sf.breezy.event.annotations.*
当然? 作ؓ(f)一个优U的框?q要有可扩展?在Breezy中开发者还可以自定义自q事g响应Annotation 来实现自q功能. 详细情况h看API.
数据l定问题?sh)?是 JTable 和JTree的问?
使用Breezy来处理该问题,有点cM于Hibernate中的xml映射数据库属性字D差不多. 可以很方便的映射.
L(fng)下面的例? 和Breezy文档:
package test;
import java.util.Date;
public class Name {
(tng) (tng) (tng)private String name = "Starwhisperer";
(tng) (tng) (tng)private Date time = new Date();
(tng) (tng) (tng)public String getName() {
(tng) (tng) (tng) (tng) (tng) (tng)return name;
(tng) (tng) (tng)}
(tng) (tng) (tng)public void setName(String name) {
(tng) (tng) (tng) (tng) (tng) (tng)this.name = name;
(tng) (tng) (tng)}
(tng) (tng) (tng)public Date getTime() {
(tng) (tng) (tng) (tng) (tng) (tng)return time;
(tng) (tng) (tng)}
(tng) (tng) (tng)public void setTime(Date time) {
(tng) (tng) (tng) (tng) (tng) (tng)this.time = time;
(tng) (tng) (tng)}
}
User.java
package test;
import java.util.Date;
import net.sf.breezy.datatable.TableField;
public class User {
(tng) (tng) (tng)@TableField(head = "名称", editable = false)
(tng) (tng) (tng)private String name;
(tng) (tng) (tng)@TableField(head = "q龄", editable = false, type = "number")
(tng) (tng) (tng)private int age;
(tng) (tng) (tng)@TableField(head = "阵营", type = "boolean", editable = false)
(tng) (tng) (tng)private boolean light;
(tng) (tng) (tng)@TableField(head = "旉", type = "time", pattern = "yyyy/MM/dd")
(tng) (tng) (tng)private Date date = new Date();
(tng) (tng) (tng)@TableField(head = "名称", property = "name", type="string")
(tng) (tng) (tng)private Name nameBean = new Name();
(tng) (tng) (tng)public Name getNameBean() {
(tng) (tng) (tng) (tng) (tng) (tng)return nameBean;
(tng) (tng) (tng)}
(tng) (tng) (tng)public void setNameBean(Name nameBean) {
(tng) (tng) (tng) (tng) (tng) (tng)this.nameBean = nameBean;
(tng) (tng) (tng)}
(tng) (tng) (tng)public boolean isLight() {
(tng) (tng) (tng) (tng) (tng) (tng)return light;
(tng) (tng) (tng)}
(tng) (tng) (tng)public void setLight(boolean light) {
(tng) (tng) (tng) (tng) (tng) (tng)this.light = light;
(tng) (tng) (tng)}
(tng) (tng) (tng)public int getAge() {
(tng) (tng) (tng) (tng) (tng) (tng)return age;
(tng) (tng) (tng)}
(tng) (tng) (tng)public void setAge(int age) {
(tng) (tng) (tng) (tng) (tng) (tng)this.age = age;
(tng) (tng) (tng)}
(tng) (tng) (tng)public String getName() {
(tng) (tng) (tng) (tng) (tng) (tng)return name;
(tng) (tng) (tng)}
(tng) (tng) (tng)public void setName(String name) {
(tng) (tng) (tng) (tng) (tng) (tng)this.name = name;
(tng) (tng) (tng)}
(tng) (tng) (tng)public Date getDate() {
(tng) (tng) (tng) (tng) (tng) (tng)return date;
(tng) (tng) (tng)}
(tng) (tng) (tng)public void setDate(Date date) {
(tng) (tng) (tng) (tng) (tng) (tng)this.date = date;
(tng) (tng) (tng)}
}
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 {
(tng) (tng) (tng)private JFrame mainFrm = new JFrame();
(tng) (tng) (tng)
(tng) (tng) (tng)protected void setUp() { (tng) (tng) (tng) (tng) (tng) (tng)
(tng) (tng) (tng) (tng) (tng) (tng)mainFrm.setSize(100, 600);
(tng) (tng) (tng) (tng) (tng) (tng)mainFrm.setLocationRelativeTo(null);
(tng) (tng) (tng) (tng) (tng) (tng)mainFrm.setLayout(new BorderLayout());
(tng) (tng) (tng) (tng) (tng) (tng)mainFrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
(tng) (tng) (tng)}
(tng) (tng) (tng)
(tng) (tng) (tng)public static void main(String[] args) {
(tng) (tng) (tng) (tng) (tng) (tng)DataTableTest test = new DataTableTest();
(tng) (tng) (tng) (tng) (tng) (tng)test.setUp();
(tng) (tng) (tng) (tng) (tng) (tng)test.testTable();
(tng) (tng) (tng)}
(tng) (tng) (tng)
(tng) (tng) (tng)public void testTable() { (tng) (tng) (tng) (tng) (tng) (tng)
(tng) (tng) (tng) (tng) (tng) (tng)java.util.List list = new LinkedList();
(tng) (tng) (tng) (tng) (tng) (tng)for(int i = 0; i < 120; i ++) {
(tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)User u = new User();
(tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)
(tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)u.setAge(33);
(tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)u.setName("Cain " + i);
(tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)list.add(u);
(tng) (tng) (tng) (tng) (tng) (tng)}
(tng) (tng) (tng) (tng) (tng) (tng)DataTableScrollPane<User> pane = DataTable.getEntityTablePane(list, User.class);
(tng) (tng) (tng) (tng) (tng) (tng)
(tng) (tng) (tng) (tng) (tng) (tng)mainFrm.add(pane, BorderLayout.CENTER); (tng) (tng) (tng) (tng) (tng) (tng)
(tng) (tng) (tng) (tng) (tng) (tng)mainFrm.setVisible(true);
(tng) (tng) (tng)}
}
映射文g:datatable-mappings.xml
<?xml version="1.0"?>
<class-mapping>
(tng) (tng) (tng)<class name="test.User">
(tng) (tng) (tng) (tng) (tng) (tng)<property name="age" head="q龄" />
(tng) (tng) (tng) (tng) (tng) (tng)<property name="light" head="光芒" type="boolean" editable="true"/>
(tng) (tng) (tng) (tng) (tng) (tng)<property name="nameBean" property="time" head="姓名" pattern="yyyy/mm/dd" type="time"/>
(tng) (tng) (tng) (tng) (tng) (tng)<property name="date" head="Date"/>
(tng) (tng) (tng) (tng) (tng) (tng)<property name="name" head="Name"/>
(tng) (tng) (tng)</class>
</class-mapping>
也是很简单的? 关于JTree的应用也是很单的? 详细情况h看用h?
更多信息请关?用户交流论坛: http://www.hexiao.cn/bbs/thread.php?fid=9 (tng)
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 都曾l对此有所介绍?Alexis q制作了(jin)一个短片向(zhn)展C怎样?NetBeans 中启?br /> (tng)
Pet StoreQ?大型 ?型Q?