Tony
Tony

Reputation: 1185

Is it possible to run 2 processes parallel in android?

I am interested if it's possible to run 2 lines of code simultaniously,

let's say if i have some function funk(); funk1(); so i want them to be executed simultaniusly

Upvotes: 1

Views: 3318

Answers (2)

MByD
MByD

Reputation: 137362

You can use Threads to achieve that easily. No need for separate processes (in most cases)

For example:

//in some method
Thread t1 = new Thread(new Runnable() {
    @Override
    public void run() {
        //function one or whatever
    }
});
t1.start();
Thread t2 = new Thread(new Runnable() {
    @Override
    public void run() {
        //function two or whatever
    }
});
t2.start();

Upvotes: 4

Guillermo Tobar
Guillermo Tobar

Reputation: 344

this is the official answer of your question.

http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html

contains simple examples and good definitions.

Upvotes: 0

Related Questions