Transient key word use

M

madhu

Hi friends I don't know how to use where to use and how to use
transient keyword in threads concept plz give me answer with small
example.
 
M

Michael Rauscher

madhu said:
Hi friends I don't know how to use where to use and how to use
transient keyword in threads concept plz give me answer with small
example.

transient is related to serialization, not to threads.

Bye
Michael
 
M

Mike Beaty

An example of transient in use would be when you place a serializable
object into the session scope of a web based application. Fields
marked as transient will not be serialized in a session failover
scenario.

-Mike
 
P

Pielmeier Markus

Hi madhu,

Hi friends I don't know how to use where to use and how to use
transient keyword in threads concept plz give me answer with small
example.

In common you use it with serialization and lazy loading. Here's a short
example:

class Name implements Serializable {

private String firstName;

private String secondName;

private transient String fullName = null;

public Name(){
}

public Name(String firstName, String secondName){
this.firstName = firstName;
this.secondName = secondName;
}

public String getFullName(){
if(fullName == null){
fullName = firstName + " " + secondName;
}

return fullName;
}

}

When you send an instance of this object "over the wire" then the fullName
member will not be transmited, but it will be generated on the first call
of the getFullName method.


Greetings,
Markus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top