Stolen Dirty Read
For the object of the synchronous asynchronous method, we design our own program, we must consider the overall problem, otherwise there will be inconsistent data errors, very classic is stolen (Dityread)
Example:
?
Package Com.nbkj.thread;public class Dityread {private String username = "hsj179540"; Private String Password = "123"; Public synchronized void SetValue (string username, string password) {this.username = username; try {thread.sleep (2000); } catch (Interruptedexception e) {e.printstacktrace (); } this.password = password; System.out.println ("SetValue The end result is: Username:" + this.username + ", Password:" + This.password); }/*synchronized */public synchronized void Getvlaue () {System.out.println ("The end result of GetValue is: Username:" + This.username + ", Password:" + This.password); public static void Main (string[] args) throws Exception {final Dityread dityread = new Dityread (); Thread t1 = new Thread (new Runnable () {@Override public void run () {Dityread.setval UE ("Zs", "ZSP"); }}, "T1"); /* Thread t2 = new Thread(New Runnable () {* * @Override public void Run () {* *}}, "T2"); */T1.start (); Thread.Sleep (1000); Dityread.getvlaue (); }}
Summarize:
? Consider the problem when you must consider the integrity of the problem, when the SetValue execution, do not want to getvalue execution, so GetValue also to lock, so as to ensure synchronization, otherwise may cause stolen.
Four characteristics of a relational database: ACID
Atomicity (atomicity), consistency (consistency), isolation (isolation), persistence (durability)
1.oracle Undo Concept:
When you perform DML operations, the old values that you perform are logged for easy rollback. Equivalent to Ctrl +z
2. Classic error: Snapshot too old
When the rollback is not found value, will error snapshot too old
Reflects the consistency of the database read pictures do not display can be copied image address to the browser view
If you have any questions, you can contact me wx:hsj179540
Consistency of the database read, stolen, multi-threaded and stolen read, Acid,undo