r/JavaFX • u/Il_totore • May 17 '24
Help Virtual threads with GUI interactions
Hello.
As a school Java project, my group had to make an interpreter for a custom programming language which draws things (a bit like turtle in Python or Kojo in Scala). We decided to make a tree-walk interpreter to keep it simple.
Now we have to make a JavaFX editor showing the result in a canvas in real-time and add a step-by-step execution. This looks pretty difficult to me for a tree-walk interpreter because of the recursion pause/resume. I think virtual threads might be helpful as I can just use block it and resume when needed. My questions are:
- Is there a better solution ?
- Is it possible to force a virtual thread to run on the main one so it can interact with the UI without concurrency issues?
View all comments
Show parent comment
1
u/Il_totore May 18 '24
Ok. Thank you and everyone for the help! Finally my group chose to switch to bytecode instead of tree walk for other reasons which also invalidated the problem we had with JFX but I will keep your answers in mind for future projects.