Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d2ac201
injecting beans
TSobala Feb 28, 2017
66471cf
XML-based configuration replaced with Java Config.
TSobala Mar 6, 2017
9eb4b9d
[BAEL-431] Exploring TestRestTemplate.
TSobala Mar 19, 2017
7a515df
Revert of evaluation task "XML-based configuration replaced with Java…
TSobala Mar 19, 2017
108d000
Revert of evaluation task "injecting beans"
TSobala Mar 19, 2017
f4198fd
[BAEL-431] fix to the tests in TestRestTemplateBasicLiveTest.
TSobala Mar 19, 2017
d978e57
Merge branch 'master' into spring-rest
TSobala Mar 21, 2017
7827b2b
Merge branch 'master' into spring-rest
pivovarit Mar 22, 2017
0cd1e8b
Merge branch 'master' into spring-rest
TSobala Mar 22, 2017
2a5a0af
Merge branch 'master' into spring-rest
zhendrikse Mar 23, 2017
8a92614
Merge branch 'master' into spring-rest
pivovarit Mar 24, 2017
19bf5a1
Merge branch 'master' into spring-rest
TSobala Mar 24, 2017
9ad7804
Merge branch 'master' into spring-rest
pivovarit Mar 25, 2017
5915d08
[BAEL-431] added more meaningful user and password for auth.
TSobala Mar 31, 2017
23cfeb9
Merge branch 'master' into spring-rest
zhendrikse Mar 31, 2017
2cf99fb
Merge pull request #1 from eugenp/master
TSobala Apr 21, 2017
cb705f2
[BAEL-820] examples of wait() and sleep() methods.
TSobala Apr 22, 2017
336deb1
Merge branch 'spring-rest' of https://github.com/TSobala/tutorials in…
TSobala Apr 22, 2017
4a4ca68
Merge branch 'master' of https://github.com/TSobala/tutorials into co…
TSobala Apr 22, 2017
c0ce017
[BAEL-820] wait() and sleep() examples.
TSobala Apr 22, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.baeldung.concurrent.sleepwait;

/***
* Example of waking up a waiting thread
*/
public class ThreadA {
private static final ThreadB b = new ThreadB();

public static void main(String... args) throws InterruptedException {
b.start();

synchronized (b) {
while (b.sum == 0) {
System.out.println("Waiting for ThreadB to complete...");
b.wait();
}

System.out.println("ThreadB has completed. Sum from that thread is: " + b.sum);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.baeldung.concurrent.sleepwait;

/***
* Example of waking up a waiting thread
*/
class ThreadB extends Thread {
int sum;

@Override
public void run() {
synchronized (this) {
int i = 0;
while (i < 100000) {
sum += i;
i++;
}
notify();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.baeldung.concurrent.sleepwait;

/***
* Example of wait() and sleep() methods
*/
public class WaitSleepExample {
private static final Object LOCK = new Object();

public static void main(String... args) throws InterruptedException {
sleepWaitInSyncronizedBlocks();
}

private static void sleepWaitInSyncronizedBlocks() throws InterruptedException {
Thread.sleep(1000); // called on the thread
System.out.println("Thread '" + Thread.currentThread().getName() + "' is woken after sleeping for 1 second");

synchronized (LOCK) {
LOCK.wait(1000); // called on the object, synchronization required
System.out.println("Object '" + LOCK + "' is woken after waiting for 1 second");
}
}

}