M
M
mihzas2014-06-15 19:08:42
Java
mihzas, 2014-06-15 19:08:42

How to pass data to the stream from the outside?

There is a thread how to pass the value of an external (relative to it) variable to it

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
FoxInSox, 2014-06-15
@FoxInSox

Very simple: a setter or just a field change. True, we must remember about local copies of the thread data and do not forget to use volatile.

public class T1 extends Thread{

  private volatile byte someByte;

  public void setData(byte someByte){
    this.someByte = someByte;
  }

  public void run(){
    //использование someByte
  }

}

I
IceJOKER, 2014-06-15
@IceJOKER

in android there are all sorts of different threads..
which one?
Thread?
AsyncTask?
you can make a variable static and refer to it, you can simply declare the variable globally and access is open, many different ways

R
Roman Vasilenko, 2014-06-15
@farewell

Describe the task more specifically, please.
Because there are several ways and it's not a fact that an external variable is the best.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question