FileDocCategorySizeDatePackage
RunnableProcessor.javaAPI DocphoneME MR2 API (J2ME)3018Wed May 02 18:00:30 BST 2007com.sun.midp.jsr82emul

RunnableProcessor

public abstract class RunnableProcessor extends Object implements Runnable
Runs emulation request processing in a separate thread.

Fields Summary
protected boolean
ready
Shows if processing can be started.
protected boolean
interrupted
Shows if processing has been interrupted.
private boolean
loop
Shows if processing should be performed repeatedly.
private Thread
thread
Thread that performs processing.
Constructors Summary
RunnableProcessor(boolean loop)
Constructs an instance.

param
loop flag to define if repeated processing required.

    
                       
      
        this.loop = loop;
        thread = new Thread(this);
        thread.start();
    
RunnableProcessor()
Constructs an instance for one time processing.

        this(false);
    
Methods Summary
public voidinterrupt()
Interrupts processing thread.

        interrupted = true;
        loop = false;
        thread.interrupt();
    
protected abstract voidprocess()
Processing procedure.

public voidrun()
Implements Runnable. Accepts and opens connection to client

        do {
            synchronized (this) {
                if (!ready) {
                    try {
                        wait();
                    } catch (InterruptedException e) {
                        return;
                    }
                }
                ready = false;
            }
            
            process();
        
        } while (loop);
    
public synchronized voidstart()
Allows one processing procedure. No processing is performed prior to this method call. For a repeatedly working processor each iteration waits for start().

        ready = true;
        notify();