Satheesh Reddy
How to create a service with single thread?
By Satheesh Reddy in Android on Jan 21 2014
  • Munesh Sharma
    Apr, 2014 22

    http://skillgun.com/question/608/android/threads/how-to-create-a-service-with-single-thread-should-i-use-intentservice-or-asynctask

    • 1
  • Rohit Gupta
    Jul, 2019 15

    A small code snipphet to demonstrate how to create a service using threads.

    A thread is created first using the Thread Class, the object of which is then used to initiate and create the service.

    Start method is used to create and execute the thread, hence invoking the service

    1. public static Thread demo(final Runnable runnable) {
    2. final Thread t = new Thread() {
    3. @Override
    4. public void run() {
    5. try {
    6. runnable.run();
    7. } finally {
    8. }
    9. }
    10. };
    11. t.start();
    12. return t;
    13. }

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS