There is a cycle in which a separate thread is launched for each id of the product id_product :
for(Int i=0; i<10; i++) { ThreadTest obj_Test = new ThreadTest(); obj_Test.run(id_product); } It turns out that the obj_Test object will be redefined each time, even if the previously created thread has not yet completed.
A program with a similar implementation works correctly and no errors appear, wondering how true such an implementation is. As I thought, the name of the object of the class ThreadTest must be unique, otherwise there may be problems with redefining objects that have not yet completed their work.
java.lang.Thread) are not multi-threaded. In order for the task to be executed in a separate thread, you must call thestart()method. To make sure of this, make a random delay insiderun()using, for example,Thread.sleepand output something to the console after the delay. - Alexandr