< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page

1320 
1321 // NamedThread --  non-JavaThread subclasses with multiple
1322 // uniquely named instances should derive from this.
1323 NamedThread::NamedThread() :
1324   NonJavaThread(),
1325   _name(NULL),
1326   _processed_thread(NULL),
1327   _gc_id(GCId::undefined())
1328 {}
1329 
1330 NamedThread::~NamedThread() {
1331   if (_name != NULL) {
1332     FREE_C_HEAP_ARRAY(char, _name);
1333     _name = NULL;
1334   }
1335 }
1336 
1337 void NamedThread::set_name(const char* format, ...) {
1338   guarantee(_name == NULL, "Only get to set name once.");
1339   _name = NEW_C_HEAP_ARRAY(char, max_name_len, mtThread);
1340   guarantee(_name != NULL, "alloc failure");
1341   va_list ap;
1342   va_start(ap, format);
1343   jio_vsnprintf(_name, max_name_len, format, ap);
1344   va_end(ap);
1345 }
1346 
1347 void NamedThread::print_on(outputStream* st) const {
1348   st->print("\"%s\" ", name());
1349   Thread::print_on(st);
1350   st->cr();
1351 }
1352 
1353 
1354 // ======= WatcherThread ========
1355 
1356 // The watcher thread exists to simulate timer interrupts.  It should
1357 // be replaced by an abstraction over whatever native support for
1358 // timer interrupts exists on the platform.
1359 
1360 WatcherThread* WatcherThread::_watcher_thread   = NULL;

1320 
1321 // NamedThread --  non-JavaThread subclasses with multiple
1322 // uniquely named instances should derive from this.
1323 NamedThread::NamedThread() :
1324   NonJavaThread(),
1325   _name(NULL),
1326   _processed_thread(NULL),
1327   _gc_id(GCId::undefined())
1328 {}
1329 
1330 NamedThread::~NamedThread() {
1331   if (_name != NULL) {
1332     FREE_C_HEAP_ARRAY(char, _name);
1333     _name = NULL;
1334   }
1335 }
1336 
1337 void NamedThread::set_name(const char* format, ...) {
1338   guarantee(_name == NULL, "Only get to set name once.");
1339   _name = NEW_C_HEAP_ARRAY(char, max_name_len, mtThread);

1340   va_list ap;
1341   va_start(ap, format);
1342   jio_vsnprintf(_name, max_name_len, format, ap);
1343   va_end(ap);
1344 }
1345 
1346 void NamedThread::print_on(outputStream* st) const {
1347   st->print("\"%s\" ", name());
1348   Thread::print_on(st);
1349   st->cr();
1350 }
1351 
1352 
1353 // ======= WatcherThread ========
1354 
1355 // The watcher thread exists to simulate timer interrupts.  It should
1356 // be replaced by an abstraction over whatever native support for
1357 // timer interrupts exists on the platform.
1358 
1359 WatcherThread* WatcherThread::_watcher_thread   = NULL;
< prev index next >