< prev index next >

test/hotspot/gtest/classfile/test_symbolTable.cpp

Print this page




 122     Semaphore done(0);
 123 
 124     Thread* THREAD = Thread::current();
 125 
 126     // Find a symbol where there will probably be only one instance.
 127     for (int i = 0; i < 100; i++) {
 128        os::snprintf(symbol_name, SYM_NAME_LENGTH, "some_symbol%d", i);
 129        TempNewSymbol ts = SymbolTable::new_symbol(symbol_name, CATCH);
 130        if (ts->refcount() == 1) {
 131          EXPECT_TRUE(ts->refcount() == 1) << "Symbol is just created";
 132          break;  // found a unique symbol
 133        }
 134     }
 135 
 136     SymbolThread* st[SYM_TEST_THREAD_COUNT];
 137     for (int i = 0; i < SYM_TEST_THREAD_COUNT; i++) {
 138       st[i] = new SymbolThread(&done);
 139       st[i]->doit();
 140     }
 141 
 142     for (int i = 0; i < 4; i++) {
 143       done.wait();
 144     }
 145   }
 146 };
 147 
 148 TEST_VM(SymbolTable, test_symbol_refcount_parallel) {
 149   mt_test_doer<DriverSymbolThread>();
 150 }


 122     Semaphore done(0);
 123 
 124     Thread* THREAD = Thread::current();
 125 
 126     // Find a symbol where there will probably be only one instance.
 127     for (int i = 0; i < 100; i++) {
 128        os::snprintf(symbol_name, SYM_NAME_LENGTH, "some_symbol%d", i);
 129        TempNewSymbol ts = SymbolTable::new_symbol(symbol_name, CATCH);
 130        if (ts->refcount() == 1) {
 131          EXPECT_TRUE(ts->refcount() == 1) << "Symbol is just created";
 132          break;  // found a unique symbol
 133        }
 134     }
 135 
 136     SymbolThread* st[SYM_TEST_THREAD_COUNT];
 137     for (int i = 0; i < SYM_TEST_THREAD_COUNT; i++) {
 138       st[i] = new SymbolThread(&done);
 139       st[i]->doit();
 140     }
 141 
 142     for (int i = 0; i < SYM_TEST_THREAD_COUNT; i++) {
 143       done.wait();
 144     }
 145   }
 146 };
 147 
 148 TEST_VM(SymbolTable, test_symbol_refcount_parallel) {
 149   mt_test_doer<DriverSymbolThread>();
 150 }
< prev index next >