473,386 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

can you do a global multi-thread "lock", that locks out everything?

I thought I need something like this, but it turns out I don't. I'm
still interested if this can be done:

Can you do a multi-thread "lock", that locks out everything else, all
other threads, without explicitly locking out those other threads?

For example, can you take a single section of code, without changing
any other code at all, and make it so that when it executes, it is the
only thing executing?

Titan

Apr 9 '07 #1
2 1568
Titan,

What's the context here? You want to make it the only thread running,
or do you want to make it so that only one thread accesses that code at a
time?

If it is the former, then no, there is no way to do it. Well, you could
code your own solution, but to be honest, that's not exactly an elegant way
of doing anything (to be honest), and I am sure you can achieve what you are
trying to do without doing that.

If you are just trying to prevent other threads from accessing that
block of code at the same time (holding them at bay until a thread exits the
code section) then that's exactly what the lock statement does.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"titan nyquist" <ti***********@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
>I thought I need something like this, but it turns out I don't. I'm
still interested if this can be done:

Can you do a multi-thread "lock", that locks out everything else, all
other threads, without explicitly locking out those other threads?

For example, can you take a single section of code, without changing
any other code at all, and make it so that when it executes, it is the
only thing executing?

Titan

Apr 9 '07 #2
I want to make it the only thread running.

I figured there was no way to do it, and I did find a more elegant
solution that did not require it.

I was just curious about it, and I can see it is an ugly way to get
things done.

Thanks,
Titan

Apr 9 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: john smile | last post by:
Hi All, I want to lock 2 tables on 2 servers using TABLOCKX hint. These tables function as semaphores in my application. It means when the tables are locked then other users will not be able to...
2
by: Gianguz | last post by:
I'd like to discuss about the opportunity to have a global objects creator that introduces into a general framework (suited for multithreading) a controlled semantic to manage globals variables...
2
by: Damir Wilder | last post by:
Hello, does someone know what kind of a lock is an "END" type lock and how/when does it appear? How can one avoid it? This lock in my case appears during a multi-row update on a table (see the...
6
by: John Carroll | last post by:
Is there a SQL query that can be run against a database that will give me all the details on any locks that are in place at the given time? I am interested in find the lock type and owner. Thank...
9
by: Jane | last post by:
Our db2diag.log is full of messages like this: 2004-05-31-17.15.10.383766 Instance:tminst1 Node:000 PID:394948(db2agent (TMDB1) 0) TID:1 Appid:GA140956.EF26.03A4B1202647 data management ...
5
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone...
1
by: awebguynow | last post by:
I'm investigating this subject, particularly DB interactions, and could use input. It seems the dominant consensus, in these discussions is "use flock() ...." I guess this would be similar to,...
3
by: Raj | last post by:
I created a refresh deferred MQT, and during full refresh there were 4 or 5 lock waits, all waiting on a 'S' lock on Internal Catalog Cache ? Can some one explain how to prevent this from happening?
37
by: Joshua Ruppert | last post by:
When I'm using FastCGI do I need to code differently than I do when using regular CGI? Because the PHP.exe processes don't go away do global variables stick around from page request to page...
14
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I just started learning Threading in C#. I read lot of articles and what I am trying to accomplish here is that I have an array of string and I want to pass the member of that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.