Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Accessing a thread
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  18 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dirk Bruere at NeoPax  
View profile  
 More options Jul 30 2012, 5:54 am
Newsgroups: comp.lang.java.programmer
From: Dirk Bruere at NeoPax <dirk.bru...@gmail.com>
Date: Mon, 30 Jul 2012 10:54:25 +0100
Local: Mon, Jul 30 2012 5:54 am
Subject: Accessing a thread
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?

--
Dirk

Full Spectrum Praxis : ZERO STATE : http://zerostate.net


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Sosman  
View profile  
 More options Jul 30 2012, 9:10 am
Newsgroups: comp.lang.java.programmer
From: Eric Sosman <esos...@ieee-dot-org.invalid>
Date: Mon, 30 Jul 2012 09:10:33 -0400
Local: Mon, Jul 30 2012 9:10 am
Subject: Re: Accessing a thread
On 7/30/2012 5:54 AM, Dirk Bruere at NeoPax wrote:

     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
esos...@ieee-dot-org.invalid


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dirk Bruere at NeoPax  
View profile  
 More options Jul 30 2012, 3:00 pm
Newsgroups: comp.lang.java.programmer
From: "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-rf4-this>
Date: Mon, 30 Jul 2012 19:00:56 GMT
Local: Mon, Jul 30 2012 3:00 pm
Subject: Accessing a thread
From: Dirk Bruere at NeoPax <dirk.bru...@gmail.com>

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?

--
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Sosman  
View profile  
 More options Jul 30 2012, 3:00 pm
Newsgroups: comp.lang.java.programmer
From: "Eric Sosman" <eric.sosman@1:261/38.remove-rf4-this>
Date: Mon, 30 Jul 2012 19:00:57 GMT
Local: Mon, Jul 30 2012 3:00 pm
Subject: Re: Accessing a thread
  To: Dirk Bruere at NeoPax
From: Eric Sosman <esos...@ieee-dot-org.invalid>

On 7/30/2012 5:54 AM, Dirk Bruere at NeoPax wrote:

     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
esos...@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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dirk Bruere at NeoPax  
View profile  
 More options Jul 30 2012, 6:53 pm
Newsgroups: comp.lang.java.programmer
From: Dirk Bruere at NeoPax <dirk.bru...@gmail.com>
Date: Mon, 30 Jul 2012 23:53:30 +0100
Local: Mon, Jul 30 2012 6:53 pm
Subject: Re: Accessing a thread
On 30/07/2012 20:00, Eric Sosman wrote:

Thanks. It's obvious now!

--
Dirk

Full Spectrum Praxis : ZERO STATE : http://zerostate.net


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roedy Green  
View profile  
 More options Jul 30 2012, 10:34 pm
Newsgroups: comp.lang.java.programmer
From: Roedy Green <see_webs...@mindprod.com.invalid>
Date: Mon, 30 Jul 2012 19:34:04 -0700
Local: Mon, Jul 30 2012 10:34 pm
Subject: Re: Accessing a thread
On Mon, 30 Jul 2012 10:54:25 +0100, Dirk Bruere at NeoPax
<dirk.bru...@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();

Keep in mind a thread is busy running its own code. Pretty well
anything you run on that thread is going to be highly disruptive.
--
Roedy Green Canadian Mind Products
http://mindprod.com
The greatest shortcoming of the human race is our inability to understand the exponential function.
 ~ Dr. Albert A. Bartlett (born: 1923-03-21 age: 89)
http://www.youtube.com/watch?v=F-QA2rkpBSY


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dirk Bruere at NeoPax  
View profile  
 More options Jul 31 2012, 2:02 pm
Newsgroups: comp.lang.java.programmer
From: "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-dpk-this>
Date: Tue, 31 Jul 2012 18:02:30 GMT
Local: Tues, Jul 31 2012 2:02 pm
Subject: Accessing a thread
From: "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-rf4-this>

From: Dirk Bruere at NeoPax <dirk.bru...@gmail.com>

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?

--
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

--- 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Sosman  
View profile  
 More options Jul 31 2012, 2:02 pm
Newsgroups: comp.lang.java.programmer
From: "Eric Sosman" <eric.sosman@1:261/38.remove-dpk-this>
Date: Tue, 31 Jul 2012 18:02:32 GMT
Local: Tues, Jul 31 2012 2:02 pm
Subject: Re: Accessing a thread
  To: Dirk Bruere at NeoPax
From: "Eric Sosman" <eric.sosman@1:261/38.remove-rf4-this>

  To: Dirk Bruere at NeoPax
From: Eric Sosman <esos...@ieee-dot-org.invalid>

On 7/30/2012 5:54 AM, Dirk Bruere at NeoPax wrote:

     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
esos...@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

--- 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dirk Bruere at NeoPax  
View profile  
 More options Jul 31 2012, 2:02 pm
Newsgroups: comp.lang.java.programmer
From: "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-dpk-this>
Date: Tue, 31 Jul 2012 18:02:35 GMT
Local: Tues, Jul 31 2012 2:02 pm
Subject: Re: Accessing a thread
  To: Eric Sosman
From: Dirk Bruere at NeoPax <dirk.bru...@gmail.com>

On 30/07/2012 20:00, Eric Sosman wrote:

Thanks. It's obvious now!

--
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roedy Green  
View profile  
 More options Jul 31 2012, 2:02 pm
Newsgroups: comp.lang.java.programmer
From: "Roedy Green" <roedy.green@1:261/38.remove-dpk-this>
Date: Tue, 31 Jul 2012 18:02:37 GMT
Local: Tues, Jul 31 2012 2:02 pm
Subject: Re: Accessing a thread
  To: Dirk Bruere at NeoPax
From: Roedy Green <see_webs...@mindprod.com.invalid>

On Mon, 30 Jul 2012 10:54:25 +0100, Dirk Bruere at NeoPax
<dirk.bru...@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();

Keep in mind a thread is busy running its own code. Pretty well anything you
run on that thread is going to be highly disruptive.
--
Roedy Green Canadian Mind Products
http://mindprod.com
The greatest shortcoming of the human race is our inability to understand the
exponential function.
 ~ Dr. Albert A. Bartlett (born: 1923-03-21 age: 89)
http://www.youtube.com/watch?v=F-QA2rkpBSY

--- 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dirk Bruere at NeoPax  
View profile  
 More options Jul 31 2012, 4:07 pm
Newsgroups: comp.lang.java.programmer
From: "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-x1c-this>
Date: Tue, 31 Jul 2012 20:07:00 GMT
Subject: Accessing a thread
From: "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-dpk-this>

From: "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-rf4-this>

From: Dirk Bruere at NeoPax <dirk.bru...@gmail.com>

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?

--
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

-+- 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

--- 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Sosman  
View profile  
 More options Jul 31 2012, 4:07 pm
Newsgroups: comp.lang.java.programmer
From: "Eric Sosman" <eric.sosman@1:261/38.remove-x1c-this>
Date: Tue, 31 Jul 2012 20:07:02 GMT
Local: Tues, Jul 31 2012 4:07 pm
Subject: Re: Accessing a thread
  To: Dirk Bruere at NeoPax
From: "Eric Sosman" <eric.sosman@1:261/38.remove-dpk-this>

  To: Dirk Bruere at NeoPax
From: "Eric Sosman" <eric.sosman@1:261/38.remove-rf4-this>

  To: Dirk Bruere at NeoPax
From: Eric Sosman <esos...@ieee-dot-org.invalid>

On 7/30/2012 5:54 AM, Dirk Bruere at NeoPax wrote:

     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
esos...@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

-+- 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

--- 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dirk Bruere at NeoPax  
View profile  
 More options Jul 31 2012, 4:07 pm
Newsgroups: comp.lang.java.programmer
From: "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-x1c-this>
Date: Tue, 31 Jul 2012 20:07:05 GMT
Local: Tues, Jul 31 2012 4:07 pm
Subject: Re: Accessing a thread
  To: Eric Sosman
From: "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-dpk-this>

  To: Eric Sosman
From: Dirk Bruere at NeoPax <dirk.bru...@gmail.com>

On 30/07/2012 20:00, Eric Sosman wrote:

Thanks. It's obvious now!

--
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

--- 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roedy Green  
View profile  
 More options Jul 31 2012, 4:07 pm
Newsgroups: comp.lang.java.programmer
From: "Roedy Green" <roedy.green@1:261/38.remove-x1c-this>
Date: Tue, 31 Jul 2012 20:07:07 GMT
Local: Tues, Jul 31 2012 4:07 pm
Subject: Re: Accessing a thread
  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_webs...@mindprod.com.invalid>

On Mon, 30 Jul 2012 10:54:25 +0100, Dirk Bruere at NeoPax
<dirk.bru...@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();

Keep in mind a thread is busy running its own code. Pretty well anything you
run on that thread is going to be highly disruptive.
--
Roedy Green Canadian Mind Products
http://mindprod.com
The greatest shortcoming of the human race is our inability to understand the
exponential function.
 ~ Dr. Albert A. Bartlett (born: 1923-03-21 age: 89)
http://www.youtube.com/watch?v=F-QA2rkpBSY

-+- 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

--- 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dirk Bruere at NeoPax  
View profile  
 More options Aug 3 2012, 11:52 am
Newsgroups: comp.lang.java.programmer
From: Dirk Bruere at NeoPax <dirk.bru...@gmail.com>
Date: Fri, 03 Aug 2012 16:52:42 +0100
Local: Fri, Aug 3 2012 11:52 am
Subject: Re: Accessing a thread
On 31/07/2012 21:07, Roedy Green wrote:

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
markspace  
View profile  
 More options Aug 3 2012, 1:07 pm
Newsgroups: comp.lang.java.programmer
From: markspace <-@.>
Date: Fri, 03 Aug 2012 10:07:24 -0700
Local: Fri, Aug 3 2012 1:07 pm
Subject: Re: Accessing a thread
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dirk Bruere at NeoPax  
View profile  
 More options Aug 3 2012, 2:54 pm
Newsgroups: comp.lang.java.programmer
From: "Dirk Bruere at NeoPax" <dirk.bruere.at.neopax@1:261/38.remove-yy0-this>
Date: Fri, 03 Aug 2012 18:54:23 GMT
Local: Fri, Aug 3 2012 2:54 pm
Subject: Re: Accessing a thread
From: Dirk Bruere at NeoPax <dirk.bru...@gmail.com>

On 31/07/2012 21:07, Roedy Green wrote:

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
markspace  
View profile  
 More options Aug 3 2012, 2:54 pm
Newsgroups: comp.lang.java.programmer
From: "markspace" <markspace@1:261/38.remove-yy0-this>
Date: Fri, 03 Aug 2012 18:54:23 GMT
Local: Fri, Aug 3 2012 2:54 pm
Subject: Re: Accessing a thread
  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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »