themeinstaller/source/src/com/nokia/tools/themeinstaller/installationmanager/Lock.java
equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Helper class for waiting asynchronous operations. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.tools.themeinstaller.installationmanager; |
|
20 |
|
21 /** |
|
22 * Helper class for waiting asynchronous operations. |
|
23 */ |
|
24 public class Lock |
|
25 { |
|
26 |
|
27 private boolean iNotify = false; |
|
28 |
|
29 /* |
|
30 * Calls wait() if unLock() hasn't been called. |
|
31 * Causes thread to wait until unLock() is called. |
|
32 */ |
|
33 synchronized public void lock() |
|
34 { |
|
35 if( !iNotify ) |
|
36 { |
|
37 try |
|
38 { |
|
39 wait(); |
|
40 } |
|
41 catch ( InterruptedException e ) |
|
42 { |
|
43 //ignore |
|
44 } |
|
45 } |
|
46 iNotify = false; |
|
47 } |
|
48 |
|
49 /* |
|
50 * Called when asynchronous operation is ready. |
|
51 * Wakes up a thread that is waiting on this object's monitor. |
|
52 */ |
|
53 synchronized public void unLock() |
|
54 { |
|
55 iNotify = true; |
|
56 notify(); |
|
57 } |
|
58 } |