?? client.java
字號:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.//// $Id: Client.java,v 1.10 2000/10/28 16:55:20 daniela Exp $package org.ozoneDB.test.multiple_access;import org.ozoneDB.*;import org.ozoneDB.core.*;import org.ozoneDB.test.*;class AccessThread extends Thread { ExternalDatabase db; public AccessThread( ExternalDatabase _db ) { db = _db; } public void run() { try { Garage garage = (Garage)db.objectForName( "MG" ); System.out.println( "thread(" + hashCode() + "): connected..." ); garage._populate( new Integer( 10 ) ); garage.printAll(); } catch (Exception e) { e.printStackTrace(); } } }public class Client extends Object { public static void main( String[] args ) throws Exception { try { RemoteDatabase db = new RemoteDatabase(); db.open( "localhost", 3333 ); // LocalDatabase db = new LocalDatabase(); // db.open ("/tmp/db", LogWriter.DEBUG3); db.reloadClasses(); RemoteDatabase db2 = new RemoteDatabase(); // db2.open ("localhost", 3333); Garage garage = (Garage)db.objectForName( "MG" ); if (garage == null) { garage = (Garage)db.createObject( GarageImpl.class.getName(), Database.Public, "MG" ); } Thread t1 = new AccessThread( db ); t1.setPriority( Thread.currentThread().getPriority() ); t1.setName( "t1" ); t1.start(); System.out.println( "wait..." ); Thread.sleep( 3000 ); System.out.println( "go on..." ); Thread t2 = new AccessThread( db ); t2.setPriority( Thread.currentThread().getPriority() ); t2.setName( "t2" ); t2.start(); Thread.sleep( 1000 ); while (t1.isAlive() || t2.isAlive()) { System.out.println( "wait for threads..." ); Thread.sleep( 1000 ); } // db.deleteObject (garage); db.close(); db2.close(); System.out.println( "deconnected..." ); } catch (Throwable e) { e.printStackTrace( System.out ); System.exit( 1 ); } } }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -