Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6896289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:01:06+00:00 2026-05-27T07:01:06+00:00

When I read the documentation, it seems the lock object is mentioned in both

  • 0

When I read the documentation, it seems the lock object is mentioned in both threading and
thread library, so I found there are 2 ways to create a lock: threading.Lock() and thread.allocate_lock(), and the return values are both of type thread.lock.

>>> a = thread.allocate_lock()
>>> b = threading.Lock()
>>> a
<thread.lock object at 0x1002ab190>
>>> b
<thread.lock object at 0x1002ab0f0>

I wonder if there’s any difference between these 2 creation methods?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:01:07+00:00Added an answer on May 27, 2026 at 7:01 am

    Python Docs itself recommends the threading module.

    Note
    The thread module has been renamed to _thread in Python 3.0. The 2to3 tool will
    automatically adapt imports when converting your sources to 3.0; however, you
    should consider using the high-level threading module instead.

    The threading module lays on top of the thread module, as stated in the threading docs

    This module constructs higher-level threading interfaces on top of the lower level
    thread module. See also the mutex and Queue modules.

    So one would assume that the locks they use are very close to identical, but the threading module wraps the thread modules calls.

    Indeed later in the threading docs, it states:

    A primitive lock is a synchronization primitive that is not owned by a particular
    thread when locked. In Python, it is currently the lowest level synchronization
    primitive available, implemented directly by the thread extension module.

    So in summary, they are most likely identical, and python itself recommends the threading module. So use that if you are in doubt.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My main question is does the Threading lock object create atomic locks? It doesn't
I read the documentation for oci_cancel but it seems to me a bit fuzzy.
I have read over the documentation, scoured the interwebs, and it seems what I
I've read the Apple Push Notification documentation and it seems this isn't possible but
I've read the documentation for parent.env() and it seems fairly straightforward - it returns
I've read akka documentation and can't produce clean understanding of thread interaction while using
I have read documentation for functions such as values and define-values that return and
I am new to OSX user space development. I've read documentation and googled before
Having read the documentation of Java's String class, it doesn't appear to support popping
I have read the documentation on this and I think I understand. An AutoResetEvent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.