code: def test_buffered_threads():
      domain = "alfa bravo charlie delta".split()
      schema = fields.Schema(name=fields.ID(unique=True, stored=True))
      with TempIndex(schema, "buffthreads") as ix:
          w = writing.BufferedWriter(ix, limit=10)
  
          class SimWriter(threading.Thread):
              def run(self):
                  for _ in xrange(5):
                      w.update_document(name=random.choice(domain))
                      time.sleep(random.uniform(0.01, 0.1))
  
          threads = [SimWriter() for _ in xrange(5)]
          for thread in threads:
              thread.start()
          for thread in threads:
              thread.join()
          w.close()
  
          with ix.reader() as r:
              assert r.doc_count() == 4
              names = sorted([d["name"] for d in r.all_stored_fields()])
              assert names == domain
  
imports: from __future__ import with_statement
  import random, time, threading
  import pytest
  from whoosh import analysis, fields, query, writing
  from whoosh.compat import b, u, xrange, text_type
  from whoosh.filedb.filestore import RamStorage
  from whoosh.util.testing import TempIndex
label_desc: Use image node_id 8 for calling a global function with example usage: test_buffered_threads() without return types