swing - how to get variable value from a java thread -


i have thread computes , generates 2 d array. need access value of 2 d array, when thread finished. how can that

        swingworker<integer, void> worker = new swingworker<integer, void>()         {             object[][] valuematrix = null;              @override             public integer doinbackground()             {                 try                 {                     valuematrix = dochemicalsynonyms(termsarray_1, termsarray_2, mview.getsavefilepath(), false, mview.getsheetname(), mview.getcategoryname(), mview.includepmids());                 }                 catch (exception e)                 {                     e.printstacktrace();                     return -1;                 }                 return 0;             }              @override             public void done()             {                 system.out.println(valuematrix[0][0]);             }         };         worker.execute(); 

dochemicalsynonyms functions generates valuematrix. how can access once thread complete, main class( global variable)

what should use done() method collect result thread. printing first value, can transfer thread use there.

beware done() invoked in edt, if need intensive operariton on it, thread necessary.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -