From: Timothy H. <tim...@ma...> - 2003-03-05 20:56:15
|
If you are going to start working with Threads and JScheme you might want to be careful when working with Swing GUIs. Swing is not thread safe so it is a good idea to execute any GUI manipulations in the AWT event queue thread. This is done by using > (javax.swing.SwingUtilities.invokeAndWait (lambda() ...code to be > executed...)) > or > (javax.swing.SwingUtilities.invokeLater (lambda() ...code to be > executed...)) They both add the code to the event Queue as a runnable, this should only be done from calls that are forked off of the main thread.... I usually also wrap the code in a tryCatch so as to catch any errors that might occur. Otherwise the errors cause the thread to halt but are otherwise not observable: > (define(invokeAndWait F) > (javax.swing.SwingUtilities.invokeAndWait (lambda() > (tryCatch > (F) > (lambda(e) (printdebug 'error {ERROR in invokeAndWait: > [F], [e]\n}))) > )) > ) > ;; where printdebug is the error printing procedure for your > application.... > Have fun, and be careful out there! ---Tim--- On Wednesday, March 5, 2003, at 03:46 PM, Geoffrey Knauth wrote: > Thanks Tim! Just what the doctor ordered. --Geoffrey > > On Wednesday, March 5, 2003, at 03:24 PM, Timothy Hickey wrote: > >> (synchronize X F) >> synchronizes the current thread on object X and blocks until it gets >> the >> lock on X, at which time it calls (F X) >> >> e.g. >> (synchronize x .wait) gets a lock on x and then gives up all locks and >> waits until it is notified >> (synchronize x .notify) gets a lock on x and then notifies some thread >> waiting on x >> >> I often use the idiom >> (synchronize g (lambda(g) ....)) >> or >> (synchronize g (lambda(_) ...)) >> >> ---Tim--- >> >> On Wednesday, March 5, 2003, at 01:58 PM, Geoffrey Knauth wrote: >> >>> I can use Java threads from JScheme. >>> >>> But can I make JScheme variables `synchronized' ? >>> >>> Geoffrey >>> >>> >>> >>> ------------------------------------------------------- >>> This SF.net email is sponsored by: Etnus, makers of TotalView, The >>> debugger for complex code. Debugging C/C++ programs can leave you >>> feeling lost and disoriented. TotalView can help you find your way. >>> Available on major UNIX and Linux platforms. Try it free. >>> www.etnus.com >>> _______________________________________________ >>> Jscheme-user mailing list >>> Jsc...@li... >>> https://lists.sourceforge.net/lists/listinfo/jscheme-user >>> >> > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Etnus, makers of TotalView, The > debugger for complex code. Debugging C/C++ programs can leave you > feeling lost and disoriented. TotalView can help you find your way. > Available on major UNIX and Linux platforms. Try it free. www.etnus.com > _______________________________________________ > Jscheme-user mailing list > Jsc...@li... > https://lists.sourceforge.net/lists/listinfo/jscheme-user > |