-
Notifications
You must be signed in to change notification settings - Fork 0
/
DatabaseLoader.java
67 lines (58 loc) · 2.11 KB
/
DatabaseLoader.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
/**
* Provides a quick way to load all the various libraries using multiple threads.
*/
public class DatabaseLoader
{
private DatabaseLoader()
{
throw new IllegalArgumentException("not instantiable");
}
public static class LoaderThread extends Thread
{
private final AtomicInteger signal;
public LoaderThread(AtomicInteger signal)
{
this.signal = signal;
}
}
/**
* Loads all libraries with multiple threads.
*/
public static void go()
{
final AtomicInteger signal = new AtomicInteger();
LoaderThread ramachandranThread = new LoaderThread(signal) {
public void run()
{
RamachandranDatabase.load();
signal.getAndIncrement();
} };
ramachandranThread.start();
LoaderThread rotamerThread = new LoaderThread(signal) {
public void run()
{
RotamerDatabase.load();
signal.getAndIncrement();
} };
rotamerThread.start();
LoaderThread omegaThread = new LoaderThread(signal) {
public void run()
{
OmegaDatabase.load();
signal.getAndIncrement();
} };
omegaThread.start();
while (true)
{
if ( signal.get() == 3 )
break;
GeneralThreadService.wait(100);
}
}
public static void main(String[] args)
{
DatabaseLoader.go();
}
}