Multithreading 使用Haskell Graphics.Gloss时发生GLUT致命错误
我遵循并创建了一个Multithreading 使用Haskell Graphics.Gloss时发生GLUT致命错误,multithreading,haskell,graphics,thread-safety,glut,Multithreading,Haskell,Graphics,Thread Safety,Glut,我遵循并创建了一个demo.hs文件,其中包含以下内容: import Graphics.Gloss window :: Display window = InWindow "Nice Window" (200, 200) (10, 10) background :: Color background = white drawing :: Picture drawing = circle 80 main :: IO () main = display window background
demo.hs
文件,其中包含以下内容:
import Graphics.Gloss
window :: Display
window = InWindow "Nice Window" (200, 200) (10, 10)
background :: Color
background = white
drawing :: Picture
drawing = circle 80
main :: IO ()
main = display window background drawing
但是,当我在终端中执行runhaskell demo.hs
时,会收到以下错误消息:
GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: nextEventMatchingMask should only be called from the Main Thread!
这个错误是什么意思?我如何修复它?我使用的是macOS Sierra版本10.12.5。Gui内容必须在macOS的主线程中完成。查看
forkOS
,了解如何在特定的操作系统线程上运行。我没有Mac电脑,但网上可能有一些关于在主线程上运行的文档Haskell@DanRobertson这里没有分叉。@Turion的确,forkOS
没有使用fork(2)
@DanRobertson,对不起,我不准确。我的意思是,在发布的示例OP中,没有涉及分叉。光泽不会分叉,它会阻塞主线程。@Turion分叉过程不同于使用多个线程。但是,如果您的声明是gloss在主线程上运行,您如何将其与上面的错误消息进行比较?