Results 1 to 4 of 4

Thread: Using Java Threads with Wowza

  1. #1
    Join Date
    Feb 2010
    Posts
    10

    Default Using Java Threads with Wowza

    Hello,

    i have quick question about using threads inside our modules for WMS2.0.
    I am seriously considering running new thread inside our module because some database queries and then lot of calculations should be done in periodical time period. I think it will be good to run this task in separate thread, because all other apps can run without waiting for it.

    I also saw that IServer object contains some WMS internal ThreadPool object.
    http://www.accesscafegroup.com/Wowza...getThreadPool()

    My question is what is the best practice to start new thread in wowza module? Can I use standard Java without using WMS internal pool or its better to use that one? In that case how can i get to server object implementing IServer interface inside one of function in module extending ModuleBase class?

    Thanks for help.

  2. #2

    Default

    up!!

    charlie? any news?

    thanks

  3. #3

    Default

    If you have a short run job then you can submit it as a job to be executed in the thread pool. All you need to do is create a class that implements Runnable and put your code in the run() method:

    Code:
    public class MyJob implements Runnable
    {
    public void run()
    {
        //put your code here
    }
    }
    If it is a task that is going to last long than a few milliseconds then it is better to create your own thread. This you can read about on google. There should be good examples. You end of creating a class that looks like this:

    Code:
    class MyThread extends Thread
    {
    public void run()
    {
      // put code in here
    }
    }
    to start the thread:
    Code:
    MyThread myThread = new MyThread();
    myThread.setDaemon(true);
    myThread.setName("myJob");
    myThread.start();
    The thread will stop when you exit the run method.

    Charlie

  4. #4
    Join Date
    Feb 2010
    Posts
    10

    Default

    Yeah, i have seen that tutorials online.
    I will consider which way to use, but thank you Charlie for helpful post.

    Archie

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •