Class ThreadBasicsExamples
java.lang.Object
net.jrodolfo.java_evolution.java01.ThreadBasicsExamples
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintRuns work in a thread created with aRunnable.intUses synchronization to protect a shared counter.
-
Constructor Details
-
ThreadBasicsExamples
public ThreadBasicsExamples()
-
-
Method Details
-
runRunnableInThread
Runs work in a thread created with aRunnable.- Returns:
- the value changed by the worker thread
- Throws:
InterruptedException- when waiting is interrupted
-
synchronizedCounter
Uses synchronization to protect a shared counter.- Returns:
- the final counter value
- Throws:
InterruptedException- when waiting is interrupted
-