KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > core > DeadlockThread


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Core License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: DeadlockThread.java,v 1.3.2.2 2003/12/21 16:01:23 per_nyfelt Exp $
8

9 package org.ozoneDB.core;
10
11
12 public class DeadlockThread extends Thread JavaDoc {
13
14     protected TransactionManager tm;
15
16     protected long sleepTime;
17
18     private volatile boolean stopRunning;
19
20     public DeadlockThread( long _sleepTime, TransactionManager _tm ) {
21         sleepTime = _sleepTime;
22         tm = _tm;
23     }
24
25     public final void stopRunning() {
26         stopRunning = true;
27
28         /* since tn.checkDeadlocks() does not do any i/o with possible blocking
29          * there is no danger in interrupting this thread
30          */

31         interrupt();
32     }
33         
34
35     public void run() {
36         for (stopRunning = false; !stopRunning; ) {
37             tm.checkDeadlocks();
38             try {
39                 sleep(sleepTime);
40             } catch (InterruptedException JavaDoc ignore) {
41             }
42         }
43     }
44 }
45
Popular Tags