Are methods in the Graphics class Thread Safe

Can methods from the Graphics class (.e.g. drawImage(), drawString(), ect..) be called from any thread? In other words, can two threads that refer to the same Graphics object step on each other methods calls?
TIA,
DB
Edited by: Darth_Bane on Apr 27, 2009 1:44 PM

No,
They are GUI activities so you should call them from the Swing Thread ( Event Disptach Thread)
Now for the JComponent the following are thread safe:
repaint(), revalidate, invalidate which can be called from any thread.
Also the listener list can be modified from any thread addListenerXX or removeListenerXX where XX is ListenerType
Regards,
Alan Mehio
London, UK

Similar Messages

  • Are static nested classes thread-safe?

    There doesn't seem to be any definitive answer to this. Given the following code, is it thread-safe?
    public class SomeMultiThreadedWebController {
    public HttpServletResponse someMethodToExecuteViaWebRequest(HttpServletRequest request) {
        simpleQueryBuilder("SELECT...").addParameter("asdf","asdf").createQuery(EMF.getEntityManager()).executeUpdate();
    protected static class SimpleQueryBuilder {
             private String queryString;
             private Map<String, Object> params = new HashMap<String, Object>();
             public SimpleQueryBuilder(String queryString) {
                  this.queryString = queryString;
             public SimpleQueryBuilder addParameter(String name, Object value) {
                  params.put(name, value);
                  return this;
             public Query createQuery(EntityManager em) {
                  Query query = em.createQuery(queryString);
                  for (Entry<String, Object> entry : params.entrySet()) {
                       query.setParameter(entry.getKey(), entry.getValue());
                  return query;
        public static SimpleQueryBuilder simpleQueryBuilder(String queryString) {
             return new SimpleQueryBuilder(queryString);
    }Forget whether or not someone would do this, as this is just an example. I'm really trying to get at whether or not the instance variables inside the static nested class are thread-safe. Thanks for any responses.

    Hello,
    I believe you understand what you're talking about, but you state it in a way that is very confusing for others.
    Let me correct this (essentially, incorrect uses of the terminology):
    I agree that thread-safe or not is for an operation, for a member, it has some sort of contextual confusion.
    Member has a much broader meaning in the [Java Language Specification|http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.4] . Even "class member" applies to both an attribute, a method, or an inner class or interface.
    I think you mean "member variable" of a class (aka "attribute" or "field"). By the way, static or not is irrelevant to the rest of the discussion.
    For an operation or a member, if there's only one thread could access it atomically in one moment, we could call it thread-safe.Mmm. I was tempted to say yes (I'm reluctant to commit myself). With an emphasis on "_The encapsulating class_ makes this member's usage thread-safe".
    Still, just synchronizing each operation on a member is not enough to make all usages "thread-safe":
    Consider a java.util.Vector: each add/get is synchronized, so it is atomic, fine.
    However if one thread adds several values, let's say 3, one by one, to a vector that initially contains 0 values, and another thread reads the vector's size() (another properly synchronized method), the reader thread may witness a size anywhere among 0, 1, 2, 3, which, depending on the business logic, may be a severely inconsistent state.
    The client code would have to make extra work (e.g. synchronizing on the vector's reference before the 3 adds) to guarantee that the usage is thread-safe.
    Thus any synchronized method(With the limit stated above)
    or immutable member (like primitive type) are thread-safe.
    Additionally for a member, if it's immutable, then it's thread-safe. You mean, immutable primitive type, or immutable object. As stated previously, an immutable reference to a mutable object isn't thread-safe.
    a static final HashMap still have thread-safe issue in practice because it's not a primitive.The underlined part is incorrect. A primitive may have thread-safety issues (unless it's immutable), and an object may not have such issues, depending on a number of factors.
    The put, get methods, which will be invoked probably, are not thread-safe although the reference to map is.Yes. And even if the put/get methods were synchronized, the client code could see consistency issues in a concurrent scenario, as demonstrated above.
    Additional considerations:
    1) read/write of primitive types are not necessarily atomic: section [ §17.7 of the JLS|http://java.sun.com/docs/books/jls/third_edition/html/memory.html#17.7] explicitly states that writing a long or double value (2 32-bits words) may not be atomic, and may be subject to consistency issues in a concurrent scenario.
    2) The Java Memory Model explicitly allows non-synchronized operations on non-volatile fields to be implemented in a "thread-unsafe" way by the JVM. Leading way to a lot of unintuitive problems such as the "Double-Checked Locking idiom is broken". Don't make clever guess on code execution path unless you properly synchronize access to variables across threads.
    Edited by: jduprez on Mar 4, 2010 9:53 AM

  • Is the Memory Suite thread safe?

    Hi all,
    Is the memory suite thread safe (at least when used from the Exporter context)?
    I ask because I have many threads getting and freeing memory and I've found that I get back null sometimes. This, I suspect, is the problem that's all the talk in the user forum with CS6 crashing with CUDA enabled. I'm starting to suspect that there is a memory management problem when there is also a lot of memory allocation and freeing going on by the CUDA driver. It seems that the faster the nVidia card the more likely it is to crash. That would suggest the CUDA driver (ie the code that manages the scheduling of the CUDA kernels) is in some way coupled to the memory use by Adobe or by Windows alloc|free too.
    I replaced the memory functions with _aligned_malloc|free and it seems far more reliable. Maybe it's because the OS malloc|free are thread safe or maybe it's because it's pulling from a different pool of memory (vs the Memory Suite's pool or the CUDA pool)
    comments?
    Edward

    Zac Lam wrote:
    The Memory Suite does pull from a specific memory pool that is set based on the user-specified Memory settings in the Preferences.  If you use standard OS calls, then you could end up allocating memory beyond the user-specified settings, whereas using the Memory Suite will help you stick to the Memory settings in the Preferences.
    When you get back NULL when allocating memory, are you hitting the upper boundaries of your memory usage?  Are you getting any error code returned from the function calls themselves?
    I am not hitting the upper memory bounds - I have several customers that have 10's of Gb free.
    There is no error return code from the ->NewPtr() call.
         PrMemoryPtr (*NewPtr)(csSDK_uint32 byteCount);
    A NULL pointer is how you detect a problem.
    Note that changing the size of the ->ReserveMemory() doesn't seem to make any difference as to whether you'll get a memory ptr or NULL back.
    btw my NewPtr size is either
         W x H x sizeof(PrPixelFormat_YUVA4444_32f)
         W x H x sizeof(PrPixelFormat_YUVA4444_8u)
    and happens concurrently on #cpu's threads (eg 16 to 32 instances at once is pretty common).
    The more processing power that the nVidia card has seems to make it fall over faster.
    eg I don't see it at all on a GTS 250 but do on a GTX 480, Quadro 4000 & 5000 and GTX 660
    I think there is a threading issue and an issue with the Memory Suite's pool and how it interacts with the CUDA memory pool. - note that CUDA sets RESERVED (aka locked) memory which can easily cause a fragmenting problem if you're not using the OS memory handler.

  • Accessing a private variable from a public method of the same class

    can anyone please tell me how to access a private variable, declared in a private method from a public method of the same class?
    here is the code, i'm trying to get the variable int[][][] grids.
    public static int[][] generateS(boolean[][] constraints)
      private static int[][][] sudokuGrids()
        int[][][] grids; // array of arrays!
        grids = new int[][][]
        {

    Are you sure that you want to have everything static here? You're possibly throwing away all the object-oriented goodness that java has to offer.
    Anyway, it seems to me that you can't get to that variable because it is buried within a method -- think scoping rules. I think that if you want to get at that variable your program design may be under the weather and may benefit from a significant refactoring in an OOP-manner.
    If you need more specific help, then ask away, but give us more information please about what you are trying to accomplish here and how you want to do this. Good luck.
    Pete
    Edited by: petes1234 on Nov 16, 2007 7:51 PM

  • What does the trim() method of the String class do in special cases?

    Looking here ( String (Java Platform SE 7 ) ), I understand that the trim() method of the String class "returns a copy of the string, with leading and trailing whitespace omitted", but I don't understand what the last special case involving Unicode characters is exactly.
    Looking here ( List of Unicode characters - Wikipedia, the free encyclopedia ), I see that U+0020 is a space character, and I also see the characters that follow the space character (such as the exclamation mark character).
    So, I decided to write a small code sample to try and replicate the behaviour that I quoted (from the API documentation of the trim method) in the multi-line comment of this same code sample. Here is the code sample.:
    public class TrimTester {
        public static void main(String[] args) {
             * "Otherwise, let k be the index of the first character in the string whose code
             * is greater than '\u0020', and let m be the index of the last character in the
             * string whose code is greater than '\u0020'. A new String object is created,
             * representing the substring of this string that begins with the character at
             * index k and ends with the character at index m-that is, the result of
             * this.substring(k, m+1)."
            String str = "aa!Hello$bb";
            System.out.println(str.trim());
    However, what is printed is "aa!Hello$bb" (without the quotes) instead of "!Hello$" (without the quotes).
    Any input to help me better understand what is going on would be greatly appreciated!

    That's not what I was thinking; I was thinking about the special case where the are characters in the String whose Unicode codes are greater than \u0020.
    In other words, I was trying to trigger what the following quote talks about.:
    Otherwise, let k be the index of the first character in the string whose code is greater than '\u0020', and let m be the index of the last character in the string whose code is greater than '\u0020'. A new String object is created, representing the substring of this string that begins with the character at index k and ends with the character at index m-that is, the result of this.substring(k, m+1).
    Basically, shouldn't the String returned be the String that is returned by the String class' substring(3,9+1) method (because the '!' and '$' characters have a Unicode code greater than \u0020)?
    It seems to not be the case, but why?

  • Getting Bad Type Error when calling a method in the proxy class

    Hi,
    I have generated the proxy classes from wsdl.
    When I am calling the methods in the proxy class from one of external class, I am getting following error.
    Can anyone please help me in resolving this issue.
    javax.xml.ws.soap.SOAPFaultException: org.xml.sax.SAXException: Bad types (interface javax.xml.soap.SOAPElement -> class com.intraware.snetmgr.webservice.data.SubscribeNetObjectReference) Message being parsed:
         at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:197)
         at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:122)
         at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:125)
         at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:95)
         at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:136)
         at $Proxy176.find(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at weblogic.wsee.jaxws.spi.ClientInstanceInvocationHandler.invoke(ClientInstanceInvocationHandler.java:84)
         at $Proxy173.find(Unknown Source)
         at com.xxx.fs.FNServices.findAccountWs(FNServices.java:132)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:92)
         at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:74)
         at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:151)
         at com.sun.xml.ws.server.sei.EndpointMethodHandlerImpl.invoke(EndpointMethodHandlerImpl.java:268)
         at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:100)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:866)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:815)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:778)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:680)
         at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:403)
         at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:532)
         at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:253)
         at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:140)
         at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:171)
         at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:708)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
         at weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:103)
         at weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:311)
         at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:336)
         at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:95)
         at weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:99)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    Thanks
    Anoop

    Hi Vlad,
    The service has not been changed since i have generated the proxy.
    I tried calling the service from soapUI and I am getting the following error now.
    Request:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:uri="uri:webservice.subscribenet.intraware.com" xmlns:uri1="uri:subscribenet.intraware.com">
    <soapenv:Header>
    <uri:SessionHeader>
    <uri:SessionID>hjkashd9sd90809dskjkds090dsj</uri:SessionID>
    </uri:SessionHeader>
    </soapenv:Header>
    <soapenv:Body>
    <uri:Find>
    <uri:SubscribeNetObjectReference>
    <uri1:ID></uri1:ID>
    <uri1:IntrawareID></uri1:IntrawareID>
    <uri1:SharePartnerID></uri1:SharePartnerID>
    </uri:SubscribeNetObjectReference>
    </uri:Find>
    </soapenv:Body>
    </soapenv:Envelope>
    Response:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header/>
    <soapenv:Body>
    <soapenv:Fault>
    <faultcode>soapenv:Server.generalException</faultcode>
    <faultstring>org.xml.sax.SAXException: WSWS3279E: Error: Unable to create JavaBean of type com.intraware.snetmgr.webservice.data.SubscribeNetObjectReference. Missing default constructor? Error was: java.lang.InstantiationException: com.intraware.snetmgr.webservice.data.SubscribeNetObjectReference. Message being parsed:</faultstring>
    </soapenv:Fault>
    </soapenv:Body>
    </soapenv:Envelope>
    Thanks
    Anoop

  • Passing values between methods in the same class

    Hi,
    How to pass internal tables or values between methods in the same class.
    How to check if the internal method in another method is initial or not.
    How to see if the method has already been executed.
    Thanks.

    Just declare the internal table as an attribute in the class - that way every method in this class has access to it.
    Since any method has access to all class attributes you can easily check if the internal table is initial or not.
    I am not aware of any standard functionality if a method has already been executed or not, one way would be to declare a class attribute for each method and set it once the method has been executed. That way every method in that class would know which method has already been executed or not.
    Hope that helps,
    Michael

  • Implementation of the hasProperties() method of the Node class

    The following snippet of code prints:
    false
    true
    which seems to be a bug.
    TextField nameField = new TextField();
    System.out.println(nameField.hasProperties());
    ObservableMap<Object, Object> props = nameField.getProperties();
    System.out.println(nameField.hasProperties());The implementation of the hasProperties() method in the Node class returns true, if the ObservableMap object for storing properties has been created. That is not what is expected from this method. I think, this method should also check if the ObservableMap has any properties.
    Can someone confirm that it is a bug?
    Thanks
    Kishori

    You can log it at http://javafx-jira.kenai.com and then, if the developers want to keep it the way it is (which they may for API compatibility purposes), they can at least document it so that a user would know what to expect without writing a test or making a potentially invalid assumption.

  • Are CacheStore's and BackingMapListener's thread safe?

    I'm implementing a JMS CacheStore and have a quick question: does Coherence ever attempt to run multiple threads concurrently across a CacheStore instance on a given node?
    Reason I ask is that only certain objects are thread-safe in the JMS spec.: Connection Factories, Destinations (i.e. a Queue) and Connections. However Sessions, Producers and Consumers are not.
    In order to improve performance, it's recommended (obviously) to try and reuse Sessions/Producers and not recreate them for every message sent. So I'd like to declare them as instance variables in my class and assign them once-only at construction time.
    I just wanted to make sure that this would be OK (i.e. Coherence would start multiple threads running across my CacheStore). Anyone any ideas?
    (NB. I'm using JMS Connection Pooling to get around this issue at the moment - as the pools are thread-safe and I can close/open them quickly as many times as I like - but this is not a part of the JMS standard, so I end up using vendor-specific classes which I'd rather not do. Likewise I could make many of these non-thread-safe objects use ThreadLocals, but this all seems a bit overkill if it isn't actually required...)
    An other issue... :)
    What about closing the connection when it's finished with? Again, it's JMS recommended best-practice to do so. How is this best accomplished, seem as though it was Coherence that created the CacheStore instance and my client code has no reference to it? Best I can think of for now is have a static method in my CacheStore class that is kicked off via an invocation-service agent. Again, if anyone has a better idea I'm all ears.
    An other issue... :)
    Does the same thread-safety hit BackMapListeners? The "receiving" end of my JMS messages is a BackingMapListener based on the Incubator Commons "AbstractMultiplexingBackingMapListener" class. So, does Coherence ever kick off multiple threads across a single BackingMapListener instance, or can I safely have the JMS Session and Consumer left open after construction as class-level members?
    Cheers,
    Steve

    stevephe wrote:
    True... But I was rather hoping I could just get someone from Oracle who wrote the stuff to comment instead! :) Don't really want to second-guess this, as there could always be unusual corner-cases that could be difficult to replicate. Still...
    I did a bit more testing on my CacheStore this morning. I removed the non JMS-standard "pooling" and just created instance variables for only those items which I know to be thread-safe (ConnectionFactory, Connection and my target queue, a "Destination" in JMS terminology) I now re-get the Session and Producer in each Cachestore method. This makes the code thread-safe and portable. TBH, it hasn't affected performance too much, so I'll leave it as it is for now (and I've put a comment in the code stating that people could move these things to ThreadLocal's if they wanted to further boost performance in their own usage cases and still keep the CacheStore thread-safe.)
    As regards the "receiving" end of these published messages, my BackingMapListener does nothing more than register a JMS MessageListener and a "connection.start()" call. This is a very short, one-off call, so shouldn't leave Coherence service threads "hanging" on anything for extended periods.
    Cheers,
    SteveHi Steve,
    to cut things short:
    1. Coherence instantiates one cache store per read-write-backing-map, therefore it needs to be thread-safe if you have a thread-pool or use write-behind.
    2. If you don't have write-behind then Coherence uses the worker thread to execute the cache store operations.
    3. If you have write-behind then generally Coherence uses the write-behind thread (this is a separate thread per write-behind-configured service) to execute the cache store operations, except for erase[All]() operations on cache.remove() or batch remove which cannot be delayed due to consistency reasons and are executed on the worker thread.
    If you don't have a thread-pool, replace worker thread with service thread.
    I don't know off my head where the refresh-ahead operation executes.
    There is a single backing-map-listener per backing map instantiated, therefore it needs to be thread-safe. BackingMapManagerContext is thread-safe, so there is no issue with sharing it across multiple threads executing on a backing-map-listener.
    Best regards,
    Robert

  • Is the reflection API thread safe?

    The obvious answer would appear to be yes, however, I have not been able to find any supporting documentation.
    I need to call the newInstance(Object[] initArgs) method on the same instance of the Constructor class from multiple threads.

    Hi,
    without knowing the reflection API too well, my guess would be, you are ok. If several threads are
    just creating new instances and you are not modifying anything used in their constructors, no problem.
    However, if you have a thread changing some class variables that are used in turn by the constructors to
    initialize the instances, you are in trouble.
    In such a case, try to encapsulate read&write access to these variables in synchronized
    methods (setter/getter).
    Good luck!
    Pete

  • Re: [SunONE-JATO] How to Access methods in the MainAppServletBase class from a view bean

    OK, fair enough.
    Look at the ServletConfig class.
    c
    Purvashada wrote:
    >
    We had that option. We decided against the
    property files as we can get this dynamically.
    There has been problems when this property
    was set incorrectly at the time of installation.
    Are there any api's to get the servername and
    port number other than through request object..
    --- "Craig V. Conover" <craig.conover@s...> wrote:
    So I guess my question is, why do you need a user
    request to get this
    information?
    You should be able to get this info when the
    application is started up,
    from a props file.
    Does this info change from day to day? If not, why
    not create a props
    file on the machine that the app is running that has
    this info?
    Then in the servlet's init method, read this prop
    file.
    Does that work for you? Not sure how a user request
    is needed to
    determine this? If it is, please explain.
    I have used this same technique for database
    properties (servername,
    instance name, uid, pwd, etc).
    On the QA machine was the properties that pointed to
    the QA database,
    and on the Production machine, the property file
    with the same name had
    props that pointed to the Production database.
    craig
    Purvashada wrote:
    It is a static data that is same for all theusers.
    It is application level data but generateddynamically
    to get the server name and the port number the appis
    running on..
    Thanks
    --- "Craig V. Conover" <craig.conover@s...>wrote:
    OK, so how does doing this only once help you.
    Wouldn't you need to do
    this for each individual end user?
    I'm not suggesting that this is request scoped,but
    maybe session scoped.
    If so, then do this in the module servlet's
    onNewSession event.
    If this is per user, then storing it staticallyis
    problematic because
    all users will be using the same data which Idon't
    think you want.
    Let me know if my assumptions are correct.
    craig
    Purvashada wrote:
    Basically, I need to pass the host url/request
    url
    to
    another server which then posts the results
    back to this server.
    I need to get the host url dynamically.
    This is what I am doing in my code to
    get the host url..
    URL =req.getScheme() + "://" +
    req.getServerName()
    +
    ":" + req.getServerPort();
    Thanks
    --- "Craig V. Conover" <craig.conover@s...>wrote:
    Correct, that is a per request event.
    Sounds like we need to figure out a newapproach.
    Please elaborate on your requirements for
    doing
    whatever it is you require.
    Maybe we can suggest an alternative, orperhaps
    reveal that it may not
    be necessary after all.
    craig
    Purvashada wrote:
    I had added this code in the
    initializeRequestContext(..)
    Hoping it would be called once.
    It looks like it is called for every
    request.
    HttpServletRequest req =requestContext.getRequest();
    setActionURL(req);
    If I add the code in the init() method
    how can I get the HttpServletRequest
    getRequest()
    Thanks
    --- "Craig V. Conover"
    <craig.conover@s...>
    wrote:
    cool.
    Be careful about how you update this URL
    when
    you
    use setURL method.
    The servlets in JATO are the only shared
    (Application scope rather than
    Request scope like ViewBeans and
    Models),
    and
    that
    you could potentially
    have sync/multithread issues. You said
    you
    were
    only
    updating once at
    the start of the App, so you should be
    fine.
    I
    assume you are doing this
    from an init method or init event in theservlet
    class? If so, no worries.
    Also, just to be sure everyone follows,
    I am
    not
    suggesting that you
    write syncronize code in the servlets asthis
    will
    be a potential bottle
    neck in your app's scalibility. This is
    not
    a
    JATO
    shortcoming as there
    are alternatives to do this sort of
    coding.
    craig
    Purvashada wrote:
    I made the method static and is
    accessible..
    --- "Craig V. Conover"<craig.conover@s...>
    wrote:
    I would assume it is a static
    method, so
    just
    do:
    MainAppServletBase.getURL()
    right?
    If not static, it probably should
    be. If
    you
    feel it
    should not be
    static, let us know why/what your
    requirements
    are.
    >
    === message truncated ===
    To download the latest version of S1AF (JATO), please visit one of the
    following locations:
    Framework + IDE plugin for Sun ONE Studio 4 Update 1, Community Edition:
    http://wwws.sun.com/software/download/products/Appl_Frmwk_2.0_CE.html
    Framework + IDE pluign for Sun ONE Studio 4 Update 1, Enterprise Edition:
    http://wwws.sun.com/software/download/products/Appl_Frmwk_2.0_EE.html
    Previous versions of JATO:
    http://www.sun.com/software/download/developer/5102.html

    OK, fair enough.
    Look at the ServletConfig class.
    c
    Purvashada wrote:
    >
    We had that option. We decided against the
    property files as we can get this dynamically.
    There has been problems when this property
    was set incorrectly at the time of installation.
    Are there any api's to get the servername and
    port number other than through request object..
    --- "Craig V. Conover" <craig.conover@s...> wrote:
    So I guess my question is, why do you need a user
    request to get this
    information?
    You should be able to get this info when the
    application is started up,
    from a props file.
    Does this info change from day to day? If not, why
    not create a props
    file on the machine that the app is running that has
    this info?
    Then in the servlet's init method, read this prop
    file.
    Does that work for you? Not sure how a user request
    is needed to
    determine this? If it is, please explain.
    I have used this same technique for database
    properties (servername,
    instance name, uid, pwd, etc).
    On the QA machine was the properties that pointed to
    the QA database,
    and on the Production machine, the property file
    with the same name had
    props that pointed to the Production database.
    craig
    Purvashada wrote:
    It is a static data that is same for all theusers.
    It is application level data but generateddynamically
    to get the server name and the port number the appis
    running on..
    Thanks
    --- "Craig V. Conover" <craig.conover@s...>wrote:
    OK, so how does doing this only once help you.
    Wouldn't you need to do
    this for each individual end user?
    I'm not suggesting that this is request scoped,but
    maybe session scoped.
    If so, then do this in the module servlet's
    onNewSession event.
    If this is per user, then storing it staticallyis
    problematic because
    all users will be using the same data which Idon't
    think you want.
    Let me know if my assumptions are correct.
    craig
    Purvashada wrote:
    Basically, I need to pass the host url/request
    url
    to
    another server which then posts the results
    back to this server.
    I need to get the host url dynamically.
    This is what I am doing in my code to
    get the host url..
    URL =req.getScheme() + "://" +
    req.getServerName()
    +
    ":" + req.getServerPort();
    Thanks
    --- "Craig V. Conover" <craig.conover@s...>wrote:
    Correct, that is a per request event.
    Sounds like we need to figure out a newapproach.
    Please elaborate on your requirements for
    doing
    whatever it is you require.
    Maybe we can suggest an alternative, orperhaps
    reveal that it may not
    be necessary after all.
    craig
    Purvashada wrote:
    I had added this code in the
    initializeRequestContext(..)
    Hoping it would be called once.
    It looks like it is called for every
    request.
    HttpServletRequest req =requestContext.getRequest();
    setActionURL(req);
    If I add the code in the init() method
    how can I get the HttpServletRequest
    getRequest()
    Thanks
    --- "Craig V. Conover"
    <craig.conover@s...>
    wrote:
    cool.
    Be careful about how you update this URL
    when
    you
    use setURL method.
    The servlets in JATO are the only shared
    (Application scope rather than
    Request scope like ViewBeans and
    Models),
    and
    that
    you could potentially
    have sync/multithread issues. You said
    you
    were
    only
    updating once at
    the start of the App, so you should be
    fine.
    I
    assume you are doing this
    from an init method or init event in theservlet
    class? If so, no worries.
    Also, just to be sure everyone follows,
    I am
    not
    suggesting that you
    write syncronize code in the servlets asthis
    will
    be a potential bottle
    neck in your app's scalibility. This is
    not
    a
    JATO
    shortcoming as there
    are alternatives to do this sort of
    coding.
    craig
    Purvashada wrote:
    I made the method static and is
    accessible..
    --- "Craig V. Conover"<craig.conover@s...>
    wrote:
    I would assume it is a static
    method, so
    just
    do:
    MainAppServletBase.getURL()
    right?
    If not static, it probably should
    be. If
    you
    feel it
    should not be
    static, let us know why/what your
    requirements
    are.
    >
    === message truncated ===
    To download the latest version of S1AF (JATO), please visit one of the
    following locations:
    Framework + IDE plugin for Sun ONE Studio 4 Update 1, Community Edition:
    http://wwws.sun.com/software/download/products/Appl_Frmwk_2.0_CE.html
    Framework + IDE pluign for Sun ONE Studio 4 Update 1, Enterprise Edition:
    http://wwws.sun.com/software/download/products/Appl_Frmwk_2.0_EE.html
    Previous versions of JATO:
    http://www.sun.com/software/download/developer/5102.html

  • Is the Illustrator SDK thread-safe?

    After searching this forum and the Illustrator SDK documentation, I can't find any references to a discussion about threading issues using the Illustrator C++ SDK. There is only a reference in some header files as to whether menu text is threaded, without any explanation.
    I take this to mean that probably the Illustrator SDK is not "thread-safe" (i.e., it is not safe to make API calls from arbitrary threads; you should only call the API from the thread that calls into your plug-in). Does anyone know this to be the case, or not?
    If it is the case, the normal way I'd write a plug-in to respond to requests from other applications for drawing services would be through a mutex-protected queue. In other words, when Illustrator calls the plug-in at application startup time, the plug-in could set up a mutually exclusive lock (a mutex), start a thread that could respond to requests from other applications, and request periodic idle processing time from the application. When such a request arrived from another application at an arbitrary time, the thread could respond by locking the queue, adding a request to the queue for drawing services in some format that the plug-in would define, and unlocking the queue. The next time the application called the plugin with an idle event, the queue could be locked, pulled from, and unlocked. Whatever request had been pulled could then be serviced with Illustrator API calls. Does anyone know whether that is a workable strategy for Illustrator?
    I assume it probably is, because that seems to be the way the ScriptingSupport.aip plug-in works. I did a simple test with three instances of a Visual Basic generated EXE file. All three were able to make overlapping requests to Illustrator, and each request was worked upon in turn, with intermediate results from each request arriving in turn. This was a simple test to add some "Hello, World" text and export some jpegs,
    repeatedly.
    Any advice would be greatly appreciated!
    Glenn Picher
    Dirigo Multimedia, Inc.
    [email protected]

    Zac Lam wrote:
    The Memory Suite does pull from a specific memory pool that is set based on the user-specified Memory settings in the Preferences.  If you use standard OS calls, then you could end up allocating memory beyond the user-specified settings, whereas using the Memory Suite will help you stick to the Memory settings in the Preferences.
    When you get back NULL when allocating memory, are you hitting the upper boundaries of your memory usage?  Are you getting any error code returned from the function calls themselves?
    I am not hitting the upper memory bounds - I have several customers that have 10's of Gb free.
    There is no error return code from the ->NewPtr() call.
         PrMemoryPtr (*NewPtr)(csSDK_uint32 byteCount);
    A NULL pointer is how you detect a problem.
    Note that changing the size of the ->ReserveMemory() doesn't seem to make any difference as to whether you'll get a memory ptr or NULL back.
    btw my NewPtr size is either
         W x H x sizeof(PrPixelFormat_YUVA4444_32f)
         W x H x sizeof(PrPixelFormat_YUVA4444_8u)
    and happens concurrently on #cpu's threads (eg 16 to 32 instances at once is pretty common).
    The more processing power that the nVidia card has seems to make it fall over faster.
    eg I don't see it at all on a GTS 250 but do on a GTX 480, Quadro 4000 & 5000 and GTX 660
    I think there is a threading issue and an issue with the Memory Suite's pool and how it interacts with the CUDA memory pool. - note that CUDA sets RESERVED (aka locked) memory which can easily cause a fragmenting problem if you're not using the OS memory handler.

  • Implements interface method at the derived class

    Hi all.
    I have a class (Derived) that extends another class (Base).
    In the base class (Base) there is a method f() with its implementation.
    In the interface (C) there is also f() method exactlly like in the base class (Base).
    The derived class (Derived) is implements the interface (C).
    My question is:
    Do i have to implement the method f() in the derived class (Derived) ?

    My guess is that you probably have to, even if it's just to call the parent's method.
    This all sounds pretty sketchy. Why don't you just make the BASE class implement your interface?

  • When do we override our own clone method not the Object class clone method

    Hi,
    I have a confusion in overriding clone method.We can create clone object by writing Object.clone() but some times I have seen writing our own clone method ,when do we write this,also clone() is defined protected and when we write our own clone it is said to write it public,why?
    Thanks
    Sumit

    protected methods can only be called in the same class and it subclass. You can make clone protected if this is all you need.
    However if you need to clone() the object from another class, it need to be public.
    This is the same for any method.
    Also as Object.clone() is protected you cannot make it private or package-local (this is true of any protected method)

  • Running different set of methods on the same class via threads

    Hello all,
    I have this issue that I am trying to deal with. It looks pretty simple to me, but maybe just a mental block I guess :)
    Now the code below will give you an idea of what I am trying to achieve. I am not sure if its possible or if there is some other better way to do this. Any help will be appreciated.
    Thanks
    public class TestClass extends Thread{
         public TestClass(){
         // Assume something goes in here.
         public void abc(){
              System.out.println("In abc");
         public void xyz(){
              System.out.println("In xyz");
         public void run(){
         //What do I put here, since my call is specific.
         public static void main(String args[]){
              TestClass t1 = new TestClass();
              t1.start();// I want t1 to call only abc()
              TestClass t2 = new TestClass();
              t2.start();// I want t2 to call only xyz
    }Edited by: mikkin on Mar 12, 2009 3:00 PM

    kogose wrote:
    you can use the Reflection API to make the desired method an instance variable:Whoa, that's a pretty big case of over-engineering (or under-engineering, depending on how you look at it) and abuse of Reflection. The real problem in the original post is that Thread isn't being used properly. You almost never want to subclass Thread, for reasons like these: your runnable target should be separate from the thread. I would organize your code like this:
    public class TestClass {
       public TestClass() {
          // Assume something goes in here.
       public void abc() {
          System.out.println("In abc");
       public void xyz() {
          System.out.println("In xyz");
       public static void main(String args[]) {
          final TestClass t1 = new TestClass();
          final TestClass t2 = new TestClass();
          new Thread(new Runnable() {
             public void run() { t1.abc(); }
          }, "t1Thread").start();
          new Thread(new Runnable() {
             public void run() { t2.xyz(); }
          }, "t2Thread").start();                   
       }

Maybe you are looking for

  • Creating a node in an XML Document

    Hi! i need to insert a new element in an existing xml document. for example, <bookinfo> <book> <bookname>A</bookname> <author>B</author> </book> <book> <bookname>C</bookname> <author>D</author> </book> </bookinfo> In this document if i want to insert

  • ColdFusion server script in multiple browser tabs

    When I run the ColdFusion server example in multiple browsers I am unable to grab sessions in each tab other then the first.  See screen shot for error message.  However if I disable cookies then I can run as many tabs as I want.  Can anyone tell me

  • Airport Extreme and Printing : is there a solution

    HI all, I have gone through many topics on printing with airport extreme and I have seen a lot of people like me having the same problem : the printer plugged to the usb port of the Airport Extreme is visible but can not print. People tried to change

  • Possible to sync ipod contacts with 2 computers but apps with only one?

    For HD space and sync-speed reasons I'd like to NOT sync applications to my laptop and just do that for/with my desktop system. I'd still like to sync contacts and calendar events w/ both systems however. Is there a way to do this? I unchecked the "s

  • Installing IAS on a P$

    I'm trying to IAS on a Pentium 4 with Windows 2000?. I know that iPlanet does not support W2K but we have it running on P3s now in W2K when we ignore the warning. The only difference is the chip. On the P4 the server will not load and I get the follo