I have Thread scenerio in which 3 classes MainThread.java, NormalWorkerClass1.java, NormalWorkerClass2.java
1 class:
class MainThread implements Runnable { private Thread thread = null;
2nd class:
class NormalWorkerClass1 { private ... private variables public static NormalWorkerClass1 getInstance() { return new NormalWorkerClass1(); } public void doMainProcess(arg..) { Files processing()
Grade 3:
class NormalWorkerClass2 { private ... private variables public static NormalWorkerClass2 getInstance() { return new NormalWorkerClass2(); } public void doMainProcess(arg..) { Files processing()
These are 3 classes. My doubts:
1) In an environment with multiple threads, that is, if both classes 2 and class 3 are available at the same time, regardless of whether 2 and 3 cause any concurrency problem, because both use some common methods and classes?
This is not part of the synchronization. Part of the web service consists of another part of the stream.
2) What happens if multiple threads access this,
NormalWorkerClass1 instance1 = NormalWorkerClass1.getInstance (); // Normal class NormalWorkerClass2 instance2 = NormalWorkerClass2.getInstance (); // for other workers
because its getInstance () method is a static method, will multiple threads share the values ββof the NormalWorkerClass1 and NormalWorkerClass2 classes?
5) Both classes NormalWorkerClass1 and NormalWorkerClass2 call the same general methods .. for example, part of the web service .. if stream1 is part of the web service and takes some time to complete. At that particular moment, another thread2 came to use the network of the service part .. this can cause any problem when fully executed. the same case with the mail part also .. will lead to any problem in the conflict of the object. I know that each thread has its own stack to execute and has copies of variables
4) Can this code cause a performance bottleneck? If so, how can I improve this code for a multi-threaded and performance-improving environment.
since I am new to this topic concurrency part ..