How to write multi-threaded code in Java?
Posted on 2013-10-01
I am writing a Java code and in this code, I call an external command by using cmd.exe and I run a batch file. Everything works fine up to this point. However, this is a UI application and after it calls the external command, the UI just waits for the other process to be completed and it you cannot click on any other button in the UI because it is just unresponsive.
As I talk to my colleagues, they recommended me to do multi-threading to solve this problem. Basically, I need to create another thread and then I need to run the external command in this thread. As a result I will be able to use the UI during the time the newly created thread is busy. This way I will use the UI and by using the stop button I will be able to stop this process at any time want.
However, I have never done anything about multi-threading until now and I am in a time pressure. I need to know how to create a new thread and do some processes in this thread.
Can you please help me how I should do this?