Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #16687
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Dirk Bruere at NeoPax <dirk.bruere@gmail.com> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Accessing a thread |
| Date | Mon, 30 Jul 2012 23:53:30 +0100 |
| Organization | Dirk Bruere at Neopax |
| Lines | 70 |
| Message-ID | <5017106A.7030004@gmail.com> (permalink) |
| References | <5016CF46.55643.calajapr@time.synchro.net> <5016CF47.55647.calajapr@time.synchro.net> |
| Reply-To | dirk.bruere@gmail.com |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net 49HfuoOrj6e6oacl3ntjyAlnPyRe7edyRdg+4KdOwZi0IIlirMRm0m3Fxl3yIRh7e7 |
| Cancel-Lock | sha1:rqUQFYIupHv2fCnsTh0Ledr1cac= |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 |
| In-Reply-To | <5016CF47.55647.calajapr@time.synchro.net> |
| X-Antivirus | avast! (VPS 120730-0, 30/07/2012), Outbound message |
| X-Antivirus-Status | Clean |
| Xref | csiph.com comp.lang.java.programmer:16687 |
Show key headers only | View raw
On 30/07/2012 20:00, Eric Sosman wrote:
> To: Dirk Bruere at NeoPax
> From: Eric Sosman<esosman@ieee-dot-org.invalid>
>
> On 7/30/2012 5:54 AM, Dirk Bruere at NeoPax wrote:
>> File1
>>
>> public class controller extends Activity {
>>
>>
>> /** Called when the activity is first created. */
>> @Override
>> public void onCreate(Bundle savedInstanceState) {
>> super.onCreate(savedInstanceState);
>> setContentView(R.layout.main);
>>
>> final LanSendThread lanSendThread = new LanSendThread();
>> lanSendThread.start();
>> ...}
>>
>> __________
>>
>> File2
>>
>> public class LanSendThread extends Thread{
>> public static Handler lanSendHandler;
>>
>> @Override
>> public void run(){
>> Looper.prepare();
>>
>> lanSendHandler = new Handler() {
>> //stuff}
>>
>> ___________
>>
>> How do I access the thread lanSendThread from another class in another
>> file?
>
> The same way you'd access it if it were an ArrayList or
> a JButton or a File: You save the reference somewhere and dish it out to
> interested parties. There must be two or three jillion ways to do this; a few
> of them are
>
> - Make `lanSendThread' a public member of the controller
> class (poor choice of name, by the way). You may or may
> not want to make that member `final'.
>
> - Make `lanSendThread' a private member of the controller
> class, and write a public getThread() method to return it.
>
> - Stash the value of `lanSendThread' in a Map or other data
> structure, and "publicize" the data structure and/or
> accessors for it.
>
> --
> Eric Sosman
> esosman@ieee-dot-org.invalid
>
> --- BBBS/Li6 v4.10 Dada-1
> * Origin: Prism bbs (1:261/38)
> --- Synchronet 3.16a-Win32 NewsLink 1.98
> Time Warp of the Future BBS - telnet://time.synchro.net:24
Thanks. It's obvious now!
--
Dirk
Full Spectrum Praxis : ZERO STATE : http://zerostate.net
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Accessing a thread "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-rf4-this> - 2012-07-30 19:00 +0000
Re: Accessing a thread "Eric Sosman" <eric.sosman@1:261/38.remove-rf4-this> - 2012-07-30 19:00 +0000
Re: Accessing a thread Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2012-07-30 23:53 +0100
Re: Accessing a thread "Roedy Green" <roedy.green@1:261/38.remove-dpk-this> - 2012-07-31 18:02 +0000
csiph-web