/* Generated automatically by jlpp - do not edit. */ #include static jakelib::lang::String* jakelib2_strings[] = {null, null, null, null, null, null, null, null, null, null}; // "(A)" static jchar chars_jakelib2_str_0[] = {40,65,41}; // "(B)" static jchar chars_jakelib2_str_1[] = {40,66,41}; // "jakelib::lang::Thread" static jchar chars_jakelib2_str_2[] = {106,97,107,101,108,105,98,58,58,108,97,110,103,58,58,84,104,114,101,97,100}; // "Starting thread A: " static jchar chars_jakelib2_str_3[] = {83,116,97,114,116,105,110,103,32,116,104,114,101,97,100,32,65,58,32}; // "Starting thread B: " static jchar chars_jakelib2_str_4[] = {83,116,97,114,116,105,110,103,32,116,104,114,101,97,100,32,66,58,32}; // "Waiting for 4 seconds..." static jchar chars_jakelib2_str_5[] = {87,97,105,116,105,110,103,32,102,111,114,32,52,32,115,101,99,111,110,100,115,46,46,46}; // "\nStopping thread A, waiting for another 4 seconds..." static jchar chars_jakelib2_str_6[] = {10,83,116,111,112,112,105,110,103,32,116,104,114,101,97,100,32,65,44,32,119,97,105,116,105,110,103,32,102,111,114,32,97,110,111,116,104,101,114,32,52,32,115,101,99,111,110,100,115,46,46,46}; // "\nDeleting thread B, waiting for another 2 seconds..." static jchar chars_jakelib2_str_7[] = {10,68,101,108,101,116,105,110,103,32,116,104,114,101,97,100,32,66,44,32,119,97,105,116,105,110,103,32,102,111,114,32,97,110,111,116,104,101,114,32,50,32,115,101,99,111,110,100,115,46,46,46}; // "jakelib::lang::Thread" static jchar chars_jakelib2_str_8[] = {106,97,107,101,108,105,98,58,58,108,97,110,103,58,58,84,104,114,101,97,100}; // "Multi Threading not available." static jchar chars_jakelib2_str_9[] = {77,117,108,116,105,32,84,104,114,101,97,100,105,110,103,32,110,111,116,32,97,118,97,105,108,97,98,108,101,46}; #line 1 "ThreadTest.jlc" // -*- c++ -*- /* * Jakelib2 - General purpose C++ library * Copyright (C) 2001 Florian Wolff (florian@donuz.de) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: ThreadTest.jlc,v 1.12 2003/09/26 15:55:26 florian Exp $ */ #include "Test.h" #include //#include //#include using namespace jakelib::util; using namespace jakelib::io; using namespace jakelib::lang; #ifdef JAKELIB_THREADS Semaphore sem; class A : public Thread { void run() { while(true) { //synchronized(sem); sleep(500); System::out->print(JAKELIB_ONDEMAND(jakelib2_strings[0], new jakelib::lang::String(chars_jakelib2_str_0, 0, 3))); Thread::yield(); } } }; class B : public Thread { void run() { while(true) { //synchronized(sem); sleep(250); System::out->print(JAKELIB_ONDEMAND(jakelib2_strings[1], new jakelib::lang::String(chars_jakelib2_str_1, 0, 3))); Thread::yield(); } } }; void threadTest() { start(JAKELIB_ONDEMAND(jakelib2_strings[2], new jakelib::lang::String(chars_jakelib2_str_2, 0, 21))); try { System::out->print(JAKELIB_ONDEMAND(jakelib2_strings[3], new jakelib::lang::String(chars_jakelib2_str_3, 0, 19))); A* a = new A(); System::out->println(a); a->start(); System::out->print(JAKELIB_ONDEMAND(jakelib2_strings[4], new jakelib::lang::String(chars_jakelib2_str_4, 0, 19))); B* b = new B(); System::out->println(b); b->start(); System::out->println(JAKELIB_ONDEMAND(jakelib2_strings[5], new jakelib::lang::String(chars_jakelib2_str_5, 0, 24))); Thread::sleep(4000); System::out->println(JAKELIB_ONDEMAND(jakelib2_strings[6], new jakelib::lang::String(chars_jakelib2_str_6, 0, 52))); Thread::sleep(4000); System::out->println(JAKELIB_ONDEMAND(jakelib2_strings[7], new jakelib::lang::String(chars_jakelib2_str_7, 0, 52))); delete b; Thread::sleep(2000); System::out->println(); } catch (Exception *e) { System::out->println(e); } } #else void threadTest() { start(JAKELIB_ONDEMAND(jakelib2_strings[8], new jakelib::lang::String(chars_jakelib2_str_8, 0, 21))); jakelib::lang::System::out->println(JAKELIB_ONDEMAND(jakelib2_strings[9], new jakelib::lang::String(chars_jakelib2_str_9, 0, 30))); } #endif