Athylus Posted March 18, 2018 Share Posted March 18, 2018 Quick question on multithreading. My script uses a GUI which has two options: What tree type to cut and another dropbown menu for how big of an area you want to cut in. Now when the area size if being adjusted I want to paint it, while the main scriptloop has not started yet. How can I implement such a function? Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted March 18, 2018 Share Posted March 18, 2018 14 minutes ago, Athylus said: Quick question on multithreading. My script uses a GUI which has two options: What tree type to cut and another dropbown menu for how big of an area you want to cut in. Now when the area size if being adjusted I want to paint it, while the main scriptloop has not started yet. How can I implement such a function? The onPaint method already runs on another Thread. The main Script loop is another Thread which starts after the onStart. Quote Link to comment Share on other sites More sharing options...
Apaec Posted March 18, 2018 Share Posted March 18, 2018 OnPaint should be called consistently from when you start the script to when you end it; it has nothing to do with onLoop So in your onPaint, perhaps have a call to your area painting class or gui class (or whatever you're doing), which asks for an optional wrapped area for example. Best Apa Quote Link to comment Share on other sites More sharing options...
dreameo Posted March 18, 2018 Share Posted March 18, 2018 There is nothing that is going to interfere with your GUI. The script hasn't started so if your GUI is open and a user is adjusting the area, the area on minimap will also adjust accordingly. After the script starts, the thread that draws is separate from the onLoop thread, there still isn't any interference. Quote Link to comment Share on other sites More sharing options...
Athylus Posted March 18, 2018 Author Share Posted March 18, 2018 Except I have this in my onStart for my GUI: synchronized(lock){ try { lock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } Which is notified by my start button on GUI Quote Link to comment Share on other sites More sharing options...
dreameo Posted March 18, 2018 Share Posted March 18, 2018 haha why are you using locks Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted March 19, 2018 Share Posted March 19, 2018 21 hours ago, Athylus said: Except I have this in my onStart for my GUI: synchronized(lock){ try { lock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } Which is notified by my start button on GUI Why would you do that ... ^^ Quote Link to comment Share on other sites More sharing options...