You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ra...@apache.org on 2005/04/27 15:41:37 UTC

cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/threadpool RunnableThread.java

raphael     2005/04/27 06:41:37

  Modified:    src/java/org/apache/jetspeed/services/threadpool
                        RunnableThread.java
  Log:
  rename the method getId() to getThreadId() to avoid naming collision with
  the java 1.5 Thread.getId()
  
  Revision  Changes    Path
  1.8       +34 -34    jakarta-jetspeed/src/java/org/apache/jetspeed/services/threadpool/RunnableThread.java
  
  Index: RunnableThread.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/threadpool/RunnableThread.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RunnableThread.java	23 Feb 2004 03:51:31 -0000	1.7
  +++ RunnableThread.java	27 Apr 2005 13:41:37 -0000	1.8
  @@ -1,12 +1,12 @@
   /*
    * Copyright 2000-2001,2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -24,21 +24,21 @@
   import org.apache.jetspeed.services.logging.JetspeedLogger;
   
   /**
  - * A thread that is used to process Runnables.  This thread will wait until it is 
  - * notified by another thread that it needs processing.  However it will only 
  + * A thread that is used to process Runnables.  This thread will wait until it is
  + * notified by another thread that it needs processing.  However it will only
    * process if getRunnable != null.
    *
    * @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
    * @author <a href="mailto:sgala@apache.org">Santiago Gala</a>
    * @version $Id$
    */
  -public class RunnableThread extends Thread 
  +public class RunnableThread extends Thread
   {
       /**
        * Static initialization of the logger for this class
  -     */    
  +     */
       private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(RunnableThread.class.getName());
  -    
  +
       private boolean running = false;
       private static int next_id = 0;
   
  @@ -55,7 +55,7 @@
       The runnable that you want to process
       */
       private Runnable runnable = null;
  -    
  +
       public RunnableThread()
       {
           super();
  @@ -83,15 +83,15 @@
        * @param tg the Threadgroup which will contain the new Thread
        * @param id an identifier for the new Thread
        */
  -    public RunnableThread( ThreadGroup tg, 
  +    public RunnableThread( ThreadGroup tg,
                              int id ) {
   
           super( tg, "RunnableThread:" + id );
           this.setPriority( Thread.MIN_PRIORITY );
  -        this.setDaemon(true);       
  +        this.setDaemon(true);
           this.id = id;
       }
  -    
  +
       /**
        * Processes the Runnable object assigned to it, whenever one
        * is available
  @@ -109,17 +109,17 @@
               //So, add ourselves to the Pool.
               //Next times we come here, we are just finished
               //one run...
  -            this.setRunning( false );                
  +            this.setRunning( false );
   
               this.setRunnable( null );
  -                
  +
               synchronized( this ) {
  -                if( this.getPriority() != 
  +                if( this.getPriority() !=
                       JetspeedThreadPoolService.DEFAULT_THREAD_PRIORITY ) {
                       //give the thread back it's default priority.
                       this.setPriority( JetspeedThreadPoolService.DEFAULT_THREAD_PRIORITY );
                   }
  -                
  +
                   //SGP I don't think it is needed. The scheduler will do its job
                   //and the thread will be released sooner. Later, it will wait
                   //until the Pool reuses it. Correct me if I'm wrong
  @@ -134,17 +134,17 @@
                     .getInstance()
                     .getService( ThreadPoolService.SERVICE_NAME ) )
                       .release( this );
  -                
  -            
  +
  +
                   //if the runnable == null wait because it has been not been
  -                //directly assigned a task.. 
  +                //directly assigned a task..
                   if ( this.getRunnable() == null ) {
  -               
  +
                       try {
                           this.wait();
                       } catch (InterruptedException e) {
  -                        //this is a normal situation.  
  -                        //the DaemonFactory may want to stop this thread form 
  +                        //this is a normal situation.
  +                        //the DaemonFactory may want to stop this thread form
                           //sleeping and call interrupt() on this thread.
                       } catch ( Throwable t ) {
                           logger.error("Throwable",  t);
  @@ -155,24 +155,24 @@
   
               }
   
  -            
  +
               if ( this.getRunnable() != null ) {
                   this.setRunning( true );
   
                   try {
  -                    
  +
                       this.getRunnable().run();
   
                   } catch ( Throwable t ) {
                       logger.error( "A problem occured while trying to run your thread", t );
                   }
  -                    
  +
               }
  -            
  +
           }
  -        
  +
       }
  -    
  +
       //misc getters/setters
   
       /**
  @@ -192,17 +192,17 @@
       public Runnable getRunnable() {
           return this.runnable;
       }
  -    
  +
       /**
        * Test whether the thread is currently executing a process
        *
  -     * @return the status of this thread. If true, the thread is currently 
  +     * @return the status of this thread. If true, the thread is currently
        * executing a Runnable process, if false it's waiting for a new process
        */
       private boolean isRunning() {
           return this.running;
       }
  -    
  +
       /**
        * Set the running status of this thread.
        *
  @@ -211,13 +211,13 @@
       private void setRunning( boolean running ) {
           this.running = running;
       }
  -    
  +
       /**
        * Get the numeric identifier of this thread
        *
        * @return the identifier of the thread
        */
  -    public int getId() {
  +    public int getThreadId() {
           return this.id;
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org