• Post Reply Bookmark Topic Watch Topic
  • New Topic

A way to do equivalent to System.getProperty() visible to Thread and lower only?  RSS feed

 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to have something akin to System properties but have them visible only to a thread/threadgroup and all threads/groups below it. Is there any way to do this? Can it be done with System properties?
 
Paul Clapham
Sheriff
Posts: 22719
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try a ThreadLocal object and put a Properties object in it. Actually if you want the object to be inherited by child threads that it creates, an InheritedThreadLocal object would be the thing to use.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dan Bizman:
I want to have something akin to System properties but have them visible only to a thread/threadgroup and all threads/groups below it.


What do you need them for?

Sounds to me that you might benefit from rethinking your design - system properties are basically global variables, and therefore should be used *very* carefully.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!