I am trying to implement multithreading in my Java GUI application to free up the interface when several intensive methods are launched. I am mainly from the background of C # development and have used Threads several times in this environment, without really experiencing any particular difficulties.
Rough:
WITH#
- Create Thread Object
- Assign a method starting with
- Top of topic
Now, on the Java application itself, this is a graphical application that has several buttons that perform different actions, the application plays MIDI notes using the MIDI API, and I have features such as playing, stopping, and adding individual notes. (The main thing to note is that I do not play MIDI files, but manually create notes / messages, playing them through the track).
There are three specific operations that I want to run in my thread.
- Play saved MIDI notes
- Display tool list through text box
- Create 100 random notes
I have a class called MIDIControl that contains all the necessary functionality, such as the actual operations for playing, stopping and generating the messages I need. There is an instance of this object created in the FooView.Java class for the GUI form itself, which means, for example:
- Click Create
- The event handler executes the "GenerateNotes" method in the FooView.Java class
- This method then executes the "Generate" method on the MIDIControl instance.
I looked at the implementation of threads through Java and from what I saw differently with the C # method, can someone explain to me how I could implement threads in my situation?
I can provide code samples if necessary, thanks for your time.
source share