Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - MultiThread

MultiThread

Put your problem here if it does not fit any of the other categories.

MultiThread

Postby khoinguyen » Fri May 02, 2008 2:56 am

Hi,
Please help me how to use multi thread in Android.
Thanks all.
khoinguyen
Freshman
Freshman
 
Posts: 5
Joined: Sat Mar 22, 2008 4:16 pm

Top

Threads

Postby daniel.kick.ass » Fri May 02, 2008 7:48 pm

Hi,

You create threads the same way you create them with any other JDK:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class MyThread extends Thread {
  2.  
  3. public void run() {
  4.  
  5. // Your implementation
  6.  
  7. }
  8.  
  9. }
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


To start this thread from your code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Thrad t = new MyThread();
  2.  
  3. t.start();
Parsed in 0.010 seconds, using GeSHi 1.0.8.4


You can also implement a runnable interface:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class MyClass extends Activity implements Runnable {
  2.  
  3. public void run() {
  4.  
  5. // Your implementation
  6.  
  7. }
  8.  
  9. }
Parsed in 0.010 seconds, using GeSHi 1.0.8.4


and to start this thread from the same class:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Thread mThread;
  2.  
  3. ...
  4.  
  5. if (mThread == null) {
  6.  
  7. mThread = new Thread(this);
  8.  
  9. mThread.start();
  10.  
  11. }
Parsed in 0.010 seconds, using GeSHi 1.0.8.4


NOTE: Using the 2nd technique will NOT allow you to close the Activity thread before the new thread terminates.

Daniel
daniel.kick.ass
Junior Developer
Junior Developer
 
Posts: 19
Joined: Sat Dec 22, 2007 9:54 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 8 guests