Starting multiple thread at the same time

后端 未结 4 669
醉酒成梦
醉酒成梦 2021-01-28 13:56

I have been trying to write some java application. What this application wants to run is processing a text file.

However, that input text file is large, (over 200mb) I t

4条回答
  •  天命终不由人
    2021-01-28 14:19

    worker1.run();
    

    calls your run method directly. To start a thread (which calls your run method in the new thread), use:

    worker1.start();
    

    (similar for worker2/3/4)

    Edit: I thought the workers were Threads, not Runnables. mvieghofer's answer is correct.

提交回复
热议问题