Transient key word use

Discussion in 'Java' started by madhu, Oct 7, 2006.

  1. madhu

    madhu Guest

    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.
     
    madhu, Oct 7, 2006
    #1
    1. Advertising

  2. madhu schrieb:
    > 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
     
    Michael Rauscher, Oct 7, 2006
    #2
    1. Advertising

  3. madhu

    Mike Beaty Guest

    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
    madhu wrote:
    > 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.
     
    Mike Beaty, Oct 7, 2006
    #3
  4. Hi madhu,

    On Sat, 07 Oct 2006 00:16:36 -0700, madhu wrote:

    > 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
     
    Pielmeier Markus, Oct 7, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TmVsc29uIFAuIFZhcmdoZXNl?=

    Disable Session or Transient Cookies

    =?Utf-8?B?TmVsc29uIFAuIFZhcmdoZXNl?=, Jul 26, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    439
    =?Utf-8?B?TmVsc29uIFAuIFZhcmdoZXNl?=
    Jul 26, 2005
  2. Se-Jin Park
    Replies:
    1
    Views:
    4,603
    Chris Smith
    Nov 18, 2004
  3. Replies:
    3
    Views:
    20,974
    Roedy Green
    Jan 21, 2006
  4. Thomas Hawtin
    Replies:
    1
    Views:
    495
  5. smackedass
    Replies:
    5
    Views:
    509
    Daniel R. Tobias
    Aug 9, 2004
Loading...

Share This Page