java - passing values from a class to another callable class -


i have class below code,

public class doctransformer implements callable<indexabledocument> {      wdoc document;     public doctransformer(map<indexfield, tokenizer> tknizermap, wdoc doc) {         this.document = doc;     }      public indexabledocument call() throws tokenizerexception {         system.out.println("inside doctrans: "+this.document.getid());      }  } 

the indexabledocument looks below,

public class indexabledocument {      wdoc doc;     public indexabledocument() {         system.out.println("this inside indexable document");     }      public void addfield(indexfield field, tstream stream) {         //todo: implement method     }      public tokenstream getstream(indexfield key) {         //todo: implement method         return null;     }      public string getdocumentidentifier() {         system.out.println(doc.getid);     }  } 

a runner class calls doctransformer. can access wdoc inside doctransformer being called runner class , object passed doctransformer. need access wdoc object inside indexabledocument. how achieve it? please explain if question needs rephrased, new threads.

you can create getter , setter wdoc use exchanger it, , don't forget make wdoc final.

exchanger<wdoc> exchanger = new exchanger<wdoc>(); \\do inside cover thread(mb main class) currentwdoc = exchanger.exchange(doc); \\ inside getter 

if nedd wdoc read . can use getter , final field


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -