Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #17094 > unrolled thread
| Started by | "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-yy0-this> |
|---|---|
| First post | 2012-08-03 18:54 +0000 |
| Last post | 2012-08-03 18:54 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.java.programmer
Re: Accessing a thread "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-yy0-this> - 2012-08-03 18:54 +0000
Re: Accessing a thread "markspace" <markspace@1:261/38.remove-yy0-this> - 2012-08-03 18:54 +0000
| From | "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-yy0-this> |
|---|---|
| Date | 2012-08-03 18:54 +0000 |
| Subject | Re: Accessing a thread |
| Message-ID | <501C156A.56053.calajapr@time.synchro.net> |
From: Dirk Bruere at NeoPax <dirk.bruere@gmail.com> On 31/07/2012 21:07, Roedy Green wrote: > To: Dirk Bruere at NeoPax > From: "Roedy Green"<roedy.green@1:261/38.remove-dpk-this> > > To: Dirk Bruere at NeoPax > From: Roedy Green<see_website@mindprod.com.invalid> > > On Mon, 30 Jul 2012 10:54:25 +0100, Dirk Bruere at NeoPax > <dirk.bruere@gmail.com> wrote, quoted or indirectly quoted someone who > said : > >> How do I access the thread lanSendThread from another class in another file? > > > // execute InParallel.run() > // in parallel to this thread on a new thread. > Thread t = new Thread ( new InParallel() ); > > // Note we call t.start(), not t.run() > // t.run() would just call run in the ordinary way. > > // Get reference to the thread running this > // code right now. > Thread runningNow = Thread.currentThread(); I still don't see how this solves my problem. In "main" (controller) I have: public static Thread txToLanThreadRef; TxToLanThread txToLanThread = new TxToLanThread(); txToLanThread.start(); txToLanThreadRef = txToLanThread.runningNow; However, when I try to access it elsewhere, this does not work controller.txToLanThreadRef. I need to access the handler in the thread so I can send it a message -- Dirk Full Spectrum Praxis : ZERO STATE : http://zerostate.net --- 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
[toc] | [next] | [standalone]
| From | "markspace" <markspace@1:261/38.remove-yy0-this> |
|---|---|
| Date | 2012-08-03 18:54 +0000 |
| Message-ID | <501C156A.56054.calajapr@time.synchro.net> |
| In reply to | #17094 |
To: Dirk Bruere at NeoPax From: markspace <-@.> On 8/3/2012 8:52 AM, Dirk Bruere at NeoPax wrote: > public static Thread txToLanThreadRef; Static variables like this are not considered best practice. Consider some alternatives, including factories, a context object, or some sort of generic message system. > However, when I try to access it elsewhere, this does not work > > controller.txToLanThreadRef. "Does not work" is a little unspecific. What error/problem do you get? Can you make a short, complete, compilable example that duplicates the problem? It should work, must work, even, according to the Java programming language. If there's an issue, it must be with the way you are using it. Please show us. --- 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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web