473,803 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1593
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.co m

"titan nyquist" <ti***********@ gmail.comwrote in message
news:11******** **************@ n59g2000hsh.goo glegroups.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
5070
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 access them and automatically they can not continue their works. I have tried using the following code, but it does not work. I always got the error :
2
1559
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 (objects and scalar-types). In the following example Global is able to create objects of any kind with and index value attached to. So a Global<0, string> is a unique string instance object allocated into the system that can be accessed from any...
2
1858
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 end of this post for the example), where I would only expect to see an IX lock on the table (present) and one X row lock for each row updated (also present). DB2 version is 7.2, EE, fixpak 8
6
20630
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 you, John
9
7363
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 sqldEscalateLocks Probe:3 Database:TMDB1 ADM5502W The escalation of "4759" locks on table "I2TM .SHPM_T" to lock intent "S" was successful. The message is always about Shared locks. What can I do to eliminate these errors?
5
5772
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 know a good place to start looking for some theory on the subject of multi user applications? I know only bits and pieces, like about transactions, but a compendium of possible approches to multi user programming would be very appreciated!
1
1738
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, in Java terms, using synchronized (objLock) { ... } This lends itself to OOP modularization, localization of reads and writes, using locks.
3
6671
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
3991
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 request, creating the need for better managment / pooling of DB connections? Josh
14
3049
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 array to each thread one by one until the processing is done. how can I pass the values one by one to myThreadprocess1 and as soon as one thread is done with the process, it should grab another item from array and process that item. How can I
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10542
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9119
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5496
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4274
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2968
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.