Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.505
diff -u -p -r1.505 theme.inc
--- includes/theme.inc	17 Aug 2009 19:14:39 -0000	1.505
+++ includes/theme.inc	19 Aug 2009 19:48:39 -0000
@@ -258,7 +258,11 @@ function _theme_save_registry($theme, $r
  * to add more theme hooks.
  */
 function drupal_theme_rebuild() {
-  cache_clear_all('theme_registry', 'cache', TRUE);
+  // Lock the Operation.
+  if (lock_acquire('drupal_theme_rebuild')) {
+    cache_clear_all('theme_registry', 'cache', TRUE);
+    lock_release('drupal_theme_rebuild');
+  }
 }
 
 /**
