4package org.qtproject.qt.android;
6import java.util.ArrayList;
7import java.util.concurrent.Semaphore;
10 private ArrayList<Runnable> m_pendingRunnables =
new ArrayList<Runnable>();
11 private boolean m_exit =
false;
12 private Thread m_qtThread =
new Thread(
new Runnable() {
17 ArrayList<Runnable> pendingRunnables;
18 synchronized (m_qtThread) {
19 if (m_pendingRunnables.size() == 0)
21 pendingRunnables =
new ArrayList<Runnable>(m_pendingRunnables);
22 m_pendingRunnables.clear();
24 for (Runnable runnable : pendingRunnables)
26 }
catch (InterruptedException
e) {
34 m_qtThread.setName(
"qtMainLoopThread");
38 public void post(
final Runnable runnable) {
39 synchronized (m_qtThread) {
40 m_pendingRunnables.add(runnable);
45 public void run(
final Runnable runnable) {
46 final Semaphore
sem =
new Semaphore(0);
47 synchronized (m_qtThread) {
48 m_pendingRunnables.add(
new Runnable() {
59 }
catch (InterruptedException
e) {
67 synchronized (m_qtThread) {
72 }
catch (InterruptedException
e) {
void acquire(int n=1)
Tries to acquire n resources guarded by the semaphore.
void release(int n=1)
Releases n resources guarded by the semaphore.
void run(final Runnable runnable)
void post(final Runnable runnable)