Concept of Thread_1
Concept of Thread_1
• Thread:
• we can define threads as a subprocess with lightweight
with the smallest unit of processes and also has
separate paths of execution.
• A Java process is a program in execution.
• A Java thread is a subset of a Java process.
• thread1.start();
• thread2.start();
• }
• In asynchronous mode, multiple threads can execute independently
without coordination. This may lead to issues like race conditions
when they access shared resources concurrently.
• class SharedResourceAsync {
• // Shared resource (in this case, a counter)
• private int counter = 0;
• thread1.start();
• thread2.start();
• }
• }