The transient and volatile keywords are used for Object serialization and thread synchronization, which are high-level topics in Java.
Transient
Transient is a type modifier and can only be used to modify fields. During Object serialization, variables marked as transient are not serialized.
Example:Class test {
Java serialization provides a mechanism for persistence object instances. When a persistent object is stored, there may be a special object data member. We do not want to use the serialization mechanism to save it. To disable serialization on a domain of a specific object, you can add the keyword transient before this domain. Transient is a keyword of the Java language used to indicate that a domain is not
Before discussing transient, it is necessary to understand the meaning of serialization in Java;The serialization of objects in Java refers to the conversion of an object into a sequence of bytes that contains the data and information of the object, a serialized object can be written to a database or file, or it can be used for network transmission. Generally, when we use cache caches (where there is not enough memory space to store locally on the har
1. Volatile
Getting started
(1) meanings of volatile keywords in Java
(2). Beginner Java multithreading: use volatile keywords with caution
Advanced
(1). Java Theory and Practice: Correct Use of volatile Variables
(2). Keyword about atomic operations and volatile ~
Extension
Java atomic operations
2. strictfp
Strictfp keywords in Java
3. Transient
Chinese Translation
In Java, this keyword can be used to make an object non-persistent.
For examp
The code is as follows:ImportJava.io.FileInputStream;Importjava.io.FileNotFoundException;ImportJava.io.FileOutputStream;Importjava.io.IOException;ImportJava.io.ObjectInputStream;ImportJava.io.ObjectOutputStream;Importjava.io.Serializable; Public classMyTestImplementsserializable{Private Static Final LongSerialversionuid = 1L; PrivateString name= "SHEEPMU"; Private transient intAge=24; PrivateBook book=NewBook ("I Am a Novel"); Public Static voidMain
Added the @ transient annotation when writing object classes.Added to the attribute declaration, but added to the get method on the Internet;1 serialization will ignoreJava serialization provides a mechanism for persistence object instances. When a persistent object is stored, there may be a special object data member. We do not want to use the serialization mechanism to save it.To disable serialization on a domain of a specific object, you can add th
num;static int staticnum;//transient keyword is a transient string pwd;transient int NUM0 that cannot be serialized; Serializabletest (string name, int num, int staticnum, String pwd, int num0) {this.name = Name;this.num = Num;this.staticnu m = staticnum;this.pwd = PWD;THIS.NUM0 = NUM0;} Public String toString () {return "name=" + name + ", num=" + num + ", stat
Transient: The object just newPersistent:sava or post-update statusAfter Detached:close or clearTest function:@Testpublic void Testsavewith3state () {Teacher t = new Teacher (); T.setname ("T1"); T.settitle ("Middle"); T.setbirthdate ( New Date ()); At this time t is the transient state session session = Sessionfactory.getcurrentsession (); Session.begintransaction (); Session.save (t); System.out.println
1. @Transient@Transient indicates that the property is not a mapping to a field in a database table, and the ORM framework ignores the property;If a property is not a field mapping for a database table, it must be marked as @transient, otherwise the ORM framework defaults to its annotation as @basic;Indicates that the field is not in the database table@Transientp
Why caching is an important element in enhancing SmartCloud input/output performance
To understand the transient storage performance in the SmartCloud environment, we set up a benchmark test using Vdbench. Vdbench is an I/O workload builder that validates data integrity and measures the performance of storage for direct attach and network connectivity. It is a free tool that is easy to use and is often used for testing and benchmarking.
We have come
Translation of TransienAdj. (adjective)1. short, momentary, instantaneous, transient, hurried, fleeting, temporary, short, transient, transient, momentary, Momentary2. Passing by, crossing, stay a while to go3.4. The Transition5. unreal, impermanentI think the last translation is more appropriate, because the essence is that the modified field is not Serializable
An exception occurred while saving Manytomany:Org.springframework.dao.InvalidDataAccessApiUsageException:org.hibernate.TransientObjectException:object References an unsaved transient instanceCause: One-way manytomany save in the reverse order, you should first save the main Terminal permission objectError code:@Transactional (readonly=false) @Lock (lockmodetype.optimistic_force_increment) @CacheEvict (value= "Permissionlist", allentries =true) Pub
1. What is transient fault?
Transient fault: I thought about how to translate this phrase for a while. It is also called an instant error. For example, a large number of projects now use WCF. If the connection times out due to transient network interruption or sudden increase in network load, in this case, the most direct way is to tell the customer that the sub
Transient and volatile two keywords one for object serialization, one for thread synchronization, is a relatively high-level topic in Java, a simple summary.TransientTransient is a type modifier that can only be used to decorate a field. In the process of object serialization, variables marked as transient are not serialized.Example:Class Test {transient int A; W
There are 3 types of Hibernate objects: Transient (Transient), persistent (persistent), and off-state (Detached). Objects that are in persistent state are also known as PO (Persistence object), and instantaneous and de-tube objects are also known as VO (Value object).1. Instantaneous stateA Java object that opens up memory space by the new command,For example: Thinksoar Thinksoar = new Thinksoar ("name", "B
The previous article introduced the left Outer Join section in the query mode. This blog article describes how to handle alarms and transient conditions in streaminsight.Transient
We use an example to explain how to use streaminsight to handle transient situations, for example:
Set the "alarm value" for a specific event. If no new event appears within 2 minutes, an alarm is generated?
As shown in the follow
One or three States (Transient, Persistent, and Detached) have three states in Hibernate. With deep understanding of it, we can better understand the running mechanism of hibernate. At the beginning, we didn't pay much attention to these concepts, later I found it important. Better understanding of the relationship between hibernate, JVM, and SQL. For JAVA objects that require persistence, there are three states in their lifecycles and they are conver
Attributes modified by static and transient in java cannot be serialized. statictransientRelated webpage: Java serialization advanced understanding of the future (verified) Class Student1package test; import java. io. serializable; public class Student1 implements Serializable {private static final long serialVersionUID = 1L; private String name; private transient String password; private static int count =
Related pages: Advanced knowledge of Java serialization http://www.360doc.com/content/13/0728/18/13247663_303173972.shtml the following programs are from "http://bbs.csdn.net/ topics/390155251 "(Verified) class Student1package Test;import Java.io.serializable;public class Student1 Implements serializable{ private static final long Serialversionuid = 1l; private St Ring name; private transient String password; private static int count = 0; N Bsp
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.