+ Message.Q.add(ret);
+ }
+
+ /** attempts to put this thread into the background to perform a blocking operation; returns false if unable to do so */
+ public static boolean suspendThread() {
+ // put ourselves in the background
+ Thread thread = Thread.currentThread();
+ if (!(thread instanceof ThreadMessage)) {
+ if (Log.on) Log.logJS(ThreadMessage.class, "attempt to perform background-only operation in a foreground thread");
+ return false;
+ }
+ ThreadMessage mythread = (ThreadMessage)thread;
+ mythread.setPriority(Thread.MIN_PRIORITY);
+ mythread.done.release();
+ return true;
+ }
+
+ /** re-enqueues this thread */
+ public static void resumeThread() {
+ ThreadMessage mythread = (ThreadMessage)Thread.currentThread();
+ Message.Q.add(mythread);
+ mythread.setPriority(Thread.NORM_PRIORITY);
+ mythread.go.block();