Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.core
Class QRunnable

    java.lang.Object
      com.trolltech.qt.QSignalEmitter
          com.trolltech.qt.QtJambiObject
              com.trolltech.qt.core.QRunnable

All Implemented Interfaces:
  QtJambiInterface

    public abstract class QRunnable

extends QtJambiObject

The `QRunnable` class is the base class for all runnable objects. The `QRunnable` class is an interface for representing a task or piece of code that needs to be executed, represented by your reimplementation of the `run()` function.

You can use `QThreadPool` to execute your code in a separate thread. `QThreadPool` deletes the `QRunnable` automatically if `autoDelete()` returns true (the default). Use `setAutoDelete()` to change the auto-deletion flag.

`QThreadPool` supports executing the same `QRunnable` more than once by calling `QThreadPool::tryStart`(this) from within the `run()` function. If `autoDelete` is enabled the `QRunnable` will be deleted when the last thread exits the run function. Calling `QThreadPool::start()` multiple times with the same `QRunnable` when `autoDelete` is enabled creates a race condition and is not recommended.

See also:
  `QThreadPool`.

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Constructor Summary
`QRunnable()` Constructs a `QRunnable`.

Method Summary
`boolean` | `autoDelete()` Returns true is auto-deletion is enabled; false otherwise.
`static QRunnable` | `fromNativePointer(QNativePointer nativePointer)` This method returns the QRunnable instance pointed to by `nativePointer`.
`abstract void` | `run()` Implement this pure virtual function in your subclass.
`void` | `setAutoDelete(boolean _autoDelete)` Enables auto-deletion if `autoDelete` is true; otherwise auto-deletion is disabled.

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QRunnable

    public QRunnable()

  Constructs a `QRunnable`. Auto-deletion is enabled by default.

See also:
  `autoDelete()`, and `setAutoDelete()`.

Method Detail

### autoDelete

    public final boolean autoDelete()

  Returns true is auto-deletion is enabled; false otherwise.

  If auto-deletion is enabled, `QThreadPool` will automatically delete this runnable after calling `run()`; otherwise, ownership remains with the application programmer.

See also:
  `setAutoDelete()`, and `QThreadPool`.

### setAutoDelete

    public final void setAutoDelete(boolean _autoDelete)

  Enables auto-deletion if `autoDelete` is true; otherwise auto-deletion is disabled.

  If auto-deletion is enabled, `QThreadPool` will automatically delete this runnable after calling `run()`; otherwise, ownership remains with the application programmer.

  Note that this flag must be set before calling `QThreadPool::start()`. Calling this function after `QThreadPool::start()` results in undefined behavior.

See also:
  `autoDelete()`, and `QThreadPool`.

### run

    public abstract void run()

  Implement this pure virtual function in your subclass.

### fromNativePointer

    public static QRunnable fromNativePointer(QNativePointer nativePointer)

  This method returns the QRunnable instance pointed to by `nativePointer`.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD