Find a way out of the ClassLoader maze (1)

保姆级教程:用GROMACS的FEP方法计算小分子结合自由能(附完整mdp配置) 本文提供了一份详细的GROMACS自由能微扰(FEP)计算教程,涵盖从系统准备、参数配置到结果分析的全流程。通过具体案例演示如何计算小分子结合自由能,包括λ窗口设计、动力学参数优化及并行化执行技巧,帮助研究者克服FEP计算中的常见问题,获得可靠的自由能数据。 阅读详情

Find a way out of the ClassLoader maze

System, current, context? Which ClassLoader should you use?

 

By Vladimir Roubtsov


Printer-friendly version Printer-friendly version | Send this article to a friend Mail this to a friend


Page 1 of 2

 

June 6, 2003

QWhen should I use
Thread.getContextClassLoader()?

A Although not frequently asked, this question is rather tough to correctly answer. It usually comes up during framework programming, when a good deal of dynamic class and resource loading goes on. In general, when loading a resource dynamically, you can choose from at least three classloaders: the system (also referred to as the application) classloader, the current classloader, and the current thread context classloader. The question above refers to the latter. Which classloader is the right one?

One choice I dismiss easily: the system classloader. This classloader handles -classpath and is programmatically accessible as ClassLoader.getSystemClassLoader(). All ClassLoader.getSystemXXX() API methods are also routed through this classloader. You should rarely write code that explicitly uses any of the previous methods and instead let other classloaders delegate to the system one. Otherwise, your code will only work in simple command-line applications, when the system classloader is the last classloader created in the JVM. As soon as you move your code into an Enterprise JavaBean, a Web application, or a Java Web Start application, things are guaranteed to break.

So, now we are down to two choices: current and context classloaders. By definition, a current classloader loads and defines the class to which your current method belongs. This classloader is implied when dynamic links between classes resolve at runtime, and when you use the one-argument version of Class.forName(), Class.getResource(), and similar methods. It is also used by syntactic constructs like X.class class literals (see "Get a Load of That Name!" for more details).

Thread context classloaders were introduced in Java 2 Platform, Standard Edition (J2SE). Every Thread has a context classloader associated with it (unless it was created by native code). It is set via the Thread.setContextClassLoader() method. If you don't invoke this method following a Thread's construction, the thread will inherit its context classloader from its parent Thread. If you don't do anything at all in the entire application, all Threads will end up with the system classloader as their context classloader. It is important to understand that nowadays this is rarely the case since Web and Java 2 Platform, Enterprise Edition (J2EE) application servers utilize sophisticated classloader hierarchies for features like Java Naming and Directory Interface (JNDI), thread pooling, component hot redeployment, and so on.

Why do thread context classloaders exist in the first place? They were introduced in J2SE without much fanfare. A certain lack of proper guidance and documentation from Sun Microsystems likely explains why many developers find them confusing.

In truth, context classloaders provide a back door around the classloading delegation scheme also introduced in J2SE. Normally, all classloaders in a JVM are organized in a hierarchy such that every classloader (except for the primordial classloader that bootstraps the entire JVM) has a single parent. When asked to load a class, every compliant classloader is expected to delegate loading to its parent first and attempt to define the class only if the parent fails.

Sometimes this orderly arrangement does not work, usually when some JVM core code must dynamically load resources provided by application developers. Take JNDI for instance: its guts are implemented by bootstrap classes in rt.jar (starting with J2SE 1.3), but these core JNDI classes may load JNDI providers implemented by independent vendors and potentially deployed in the application's -classpath. This scenario calls for a parent classloader (the primordial one in this case) to load a class visible to one of its child classloaders (the system one, for example). Normal J2SE delegation does not work, and the workaround is to make the core JNDI classes use thread context loaders, thus effectively "tunneling" through the classloader hierarchy in the direction opposite to the proper delegation.

By the way, the previous paragraph may have reminded you of something else: Java API for XML Parsing (JAXP). Yes, when JAXP was just a J2SE extension, the XML parser factories used the current classloader approach for bootstrapping parser implementations. When JAXP was made part of the J2SE 1.4 core, the classloading changed to use thread context classloaders, in complete analogy with JNDI (and confusing many programmers along the way). See what I mean by lack of guidance from Sun?

After this introduction, I have come to the crux of the matter: neither of the remaining two choices is the right one under all circumstances. Some believe that thread context classloaders should become the new standard strategy. This, however, creates a very messy classloading picture if various JVM threads communicate via shared data, unless all of them use the same context loader instance. Furthermore, delegating to the current classloader is already a legacy rule in some existing situations like class literals or explicit calls to Class.forName() (which is why, by the way, I recommend (again, see "Get a Load of That Name!") avoiding the one-argument version of this method). Even if you make an explicit effort to use only context loaders whenever you can, there will always be some code not under your control that delegates to the current loader. This uncontrolled mixing of delegation strategies sounds rather dangerous.

To make matters worse, certain application servers set context and current classloaders to different ClassLoader instances that have the same classpaths and yet are not related as a delegation parent and child. Take a second to think about why this is particularly horrendous. Remember that the classloader that loads and defines a class is part of the internal JVM's ID for that class. If the current classloader loads a class X that subsequently executes, say, a JNDI lookup for some data of type Y, the context loader could load and define Y. This Y definition will differ from the one by the same name but seen by the current loader. Enter obscure class cast and loader constraint violation exceptions.

This confusion will probably stay with Java for some time. Take any J2SE API with dynamic resource loading of any kind and try to guess which loading strategy it uses. Here is a sampling:

 

  • JNDI uses context classloaders
  • Class.getResource() and Class.forName() use the current classloader
  • JAXP uses context classloaders (as of J2SE 1.4)
  • java.util.ResourceBundle uses the caller's current classloader
  • URL protocol handlers specified via java.protocol.handler.pkgs system property are looked up in the bootstrap and system classloaders only
  • Java Serialization API uses the caller's current classloader by default

Those class and resource loading strategies must be the most poorly documented and least specified area of J2SE.

Next page >
Page 1 Find a way out of the ClassLoader maze
Page 2 What is a Java programmer to do?

Printer-friendly version Printer-friendly version | Send this article to a friend Mail this to a friend


 

WIFI CSI动作识别数据集全解析:从数据采集到深度学习应用 本文全面解析了利用商用Wi-Fi设备的信道状态信息进行动作识别的完整流程。文章以经典WiSA数据集为例,深入剖析了CSI数据的采集原理、结构特点,并详细阐述了从原始数据预处理、特征工程到深度学习模型(如CNN-LSTM融合架构)构建与优化的关键技术,旨在为研究者提供从数据到应用的全链路实战指南。 阅读详情

相关推荐

Python Opencv cv2提取图像中某种特定颜色区域(例如黑字白纸背景下的红色公章提取),并将纯色背景透明化

拜拜PHOTOSHOP- 领导突然让我帮他把公章从图片中抠出来,在确保了不是要做坏事的情况下,我打开了PHOTOSHOP,用魔棒工具一点一点抠,但由于魔棒工具的原理是对比临近区域像素差值,导致封闭字体中的区域无法剔除,而且一点一点抠非常麻烦,愤而PYTHON,使用CV2完美解决。 效果如下(马赛克是我添加的): 任务就是把蓝色的公章抠出来。 效果如上。 代码如下: import cv2 import numpy as np src = cv2.imread(r"imagepath")#这里填你的原图像路

qq_43670549的博客 1万+

【转】Find a way out of the ClassLoader maze (1)

Find a way out of the ClassLoader maze System, current, context? Which ClassLoader should you use? By Vladimir Roubtsov Printer-friendly version | Mail this to a friend Page 1 of 2 ...

weixin_38170255的博客 160

TC397 EB配置ADC软件触发:从零实现周期采样与中断处理

本文详细介绍了如何在Infineon AURIX TC397芯片上使用EB Tresos工具配置ADC软件触发,实现周期采样与中断处理。通过硬件连接、EB模块配置、代码初始化及数据处理的全流程解析,帮助开发者快速掌握ADC软件触发技术,提升嵌入式系统开发效率。

root9的博客 236

Find a way out of the ClassLoader maze

关于讲类加载的文章向来比较少,一来大多数应用开发者

大白日梦想家的专栏 519

odoo19/18集成reportbro 打印插件 完美支持静默打印

ReportBro设计器 一个用于创建PDF和XLSX报告模板的javascript插件。ReportBro Designer可以轻松集成到您的Web应用程序中。每个人都可以设计和编辑文档模板,并直接在浏览器中预览它们。可以使用服务器上的 (有关完整的文档和演示,请参阅上的ReportBro项目网站。reportBro官方没有提供。测试环境:odoo17社区版。2.产品标签打印设计。

zxltwins的博客 2776

使用Docker搭建MaxKB智能体平台

【代码】使用Docker搭建MaxKB智能体平台。

janthinasnail的博客 719

Find a way out of the ClassLoader maze (2)

Find a way out of the ClassLoader maze System, current, context? Which ClassLoader should you use?  Summary-->--> Printer-friendly version | Mail this to a friendPage 2 of 2

DeepNightTwo的专栏 1235

学Simulink——基于扩展卡尔曼滤波(EKF)的列车牵引电机转子温度在线估计仿真

本文介绍了一种基于扩展卡尔曼滤波(EKF)的列车牵引电机转子温度在线估计方法,通过Simulink建模实现。文章首先阐述了EKF在估计电机转子温度中的优势,即利用易测量信号(如电流、电压、转速)在线估计难以直接测量的转子温度,并分析了温升对电机性能的影响。随后详细讲解了电机热电增广模型的构建,包括定子电阻温度关系、一阶热近似模型和PMSM的dq轴方程。接着,文章提供了Simulink建模的详细步骤,包括PMSM+FOC电流环的搭建、EKF算法的实现(推荐使用ExtendedKalmanFilter块或MAT

xiaoheshang_123的博客 59

Find a way out of the ClassLoader maze---走出ClassLoader迷宫

  在上篇文章中,遇到朋友提到上下文加载器的问题。一直有很多疑惑。今天在CSDN上正巧看到一篇关于上下文加载器的译文(这方面网上相关的资料真的太少了)。感觉有所启发。于是搜了搜原文。连同译文一块作为收藏。译文来自:http://blog.sina.com.cn/u/4b6047bc0100096v对于类加载器,普通Java应用开发人员不需要了解太多。但对于系统开发人员,正确理解Java的类加载器模...

realsmy---久城的学习室 198

基于Abaqus的横向各向同性线弹性理想塑性材料模型的umat子程序实现——以Fortran为例,带您揭秘弹性塑性模型编程之道

通过以上步骤,我们已经在Abaqus中使用Fortran实现了横向各向同性线弹性理想塑性材料模型的umat子程序。在实际应用中,我们需要根据具体的材料特性和加载条件来调整模型参数和计算过程。尽管我在这篇文章中尽力提供了详细的教程,但由于我自身的知识限制和经验不足,可能会有误解或错误。我希望大家在学习过程中能多思考,多实践,多交流,以更好地理解和掌握这个主题。

qq_38334677的博客 1692

Python爬虫博客:如何抓取时事新闻信息 —— 从各大新闻网站获取实时新闻数据

发送请求:向目标新闻网站发送 HTTP 请求,获取网页内容。解析网页:使用解析库(如)从网页中提取新闻标题、摘要、内容、发布时间等。绕过反爬虫机制:使用代理、设置请求头、模拟浏览器行为等策略绕过反爬虫技术。数据存储与清洗:将抓取的数据保存到本地文件或数据库中,并进行清洗,确保数据的可用性。在抓取过程中,我们还会面对很多实际问题,比如反爬虫技术、分页抓取、动态加载的内容等。接下来,我们将逐步介绍如何使用不同技术抓取静态和动态网页,并对抓取的内容进行处理。Scrapy。

2201_76125261的博客 2144

Find a way out of the ClassLoader maze---走出ClassLoader迷宫 ( 转 )

在上篇文章中,遇到朋友提到上下文加载器的问题。一直有很多疑惑。今天在CSDN上正巧看到一篇关于上下文加载器的译文(这方面网上相关的资料真的太少了)。感觉有所启发。于是搜了搜原文。连同译文一块作为收藏。译文来自:http://blog.sina.com.cn/u/4b6047bc0100096v对于类加载器,普通Java应用开发人员不需要了解太多。但对于系统开发人员,正确理解Java的类加载器模型是

esidemayi的专栏 677

基于STM32L4XX、HAL库的SIM65M定位模块驱动程序设计

SIM65M是一款基于4G LTE Cat.1的无线通信模块,支持最大下行速率10Mbps和上行速率5Mbps。它兼容多种网络协议(TCP/UDP/HTTP/HTTPS/FTP/MQTT等),适用于物联网应用。PC0 <---> PWRKEY (模块电源控制)PC1 <---> RESET (模块复位)支持LTE-FDD/LTE-TDD。工作电压:3.4V~4.2V。

zhusl6688的博客 197

Java EE 进阶:11. SpringBoot 统一功能处理(第二弹):DispatcherServlet 源码分析+适配器模式

Java EE 进阶:11. SpringBoot 统一功能处理(第二弹):DispatcherServlet 源码分析+适配器模式

要努力去发光,而不是被照亮~ 331

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

Spring Boot + LangChain4j 实战多模态:上传截图、流式输出、单 Jar 部署全流程

本文介绍一个纯Java实现的截图转文字Demo,基于JDK21 + Spring Boot 3.5.16 + LangChain4j 1.20.2 + Vue3,支持灵活传参、流式输出与Markdown自动折叠。无需Python或GPU,仅通过云端多模态接口即可完成图像理解与文本生成。重点解决接口变更、流式调用、图片压缩、并发限流等实战坑点,强调Java在多模态场景下的可行性与工程优势。源码已开源,一键运行即可体验。

sch7979的博客 653

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

beaTunes 6.0.3 完整中文化实践:界面 + 帮助本地化、一个可回退的离线包,外加一次不靠调内存的卡顿优化

本文基于beaTunes 6.0.3,通过修改资源包与覆盖帮助目录,实现界面1646/1674键、帮助27页全中文(界面约98%、帮助100%),仅剩搜索索引因技术限制未汉化。不修改class文件,避免风险。通过PowerShell脚本安全注入语言包、覆盖HTML内容,并保留完整备份与回退机制。实测表明,软件卡顿非内存不足,无需调整-Xmx,关键在于正确配置JVM参数。强调操作需在正版授权下进行,禁止分发修改版,确保安全可控。

wdhuag的博客 249

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

《阿里巴巴 Java 开发手册》的 MySQL 核心规范

既然你平时经常自己练习表结构设计,那这份提炼自《阿里巴巴 Java 开发手册》的 MySQL 核心规范,绝对是你日常建表和写 SQL 时的“避坑宝典”。我帮你把最核心的【强制】级别规范,按和。

qq_26889291的博客 320

Java 面向对象基础(类、对象、封装)

System.out.println(name + "正在学习");System.out.println("年龄非法");• 类:模板、图纸,抽象的;对象:根据模板new出来的实例,具体的。• private 私有:只能在本类里面访问,外面不能直接点调用。if(a>0 && a<120){ // 加校验。• this.成员变量:区分成员变量和局部变量(同名的时候)• this(...):调用本类其他构造方法,必须写在第一行。// 成员变量(属性)// 成员方法(行为)// set 设置年龄。

2601_95661678的博客 189

Hibernate 中 getCurrentSession 与 openSession 的区别详解

与的本质区别在于Session 的归属与生命周期由谁管理是"我创建、我负责关闭",控制权在开发者手里;是"框架创建、框架负责关闭",控制权交给上下文(线程或 JTA 事务)。理解这一点后,再结合项目的事务管理方式(编程式事务还是声明式事务、是否使用 Spring、是否使用 JTA),就能做出合理的选择。

2601_96710005的博客 368

字节流基础

IO(Input/Output)流用于实现程序与外部设备(文件、网络、控制台等)之间的数据传输,Java 中所有 IO 相关类都位于java.io包下。输入流:将外部设备的数据读取到程序中输出流:将程序中的数据写出到外部设备字节流:以字节为最小单位传输数据,可处理所有类型文件(文本、图片、音频、视频等)字符流:以字符为单位传输数据,专门用于处理纯文本文件。

Sarvartha的博客 195

MCP 面试高频考点:把内部 REST API 封装成可审计 Tools,OpenTelemetry 与最小权限怎么落地

面试场景 某公司有一批内部 REST API(订单查询、退款发起、客户资料读取等),希望把它们封装成 MCP Tools,让内部的 AI 应用通过 MCP Client 调用。安全团队的要求是: 每次调用都能审计到“谁、何时、调了哪个 To。

a3258264204的博客 193

c++ constexpr 关键字

constexpr。

拒绝AI文,努力在AI时代写出感动人心的好文章 398

集群中为什么要有主节点?

理解了这一点,也就理解了为什么几乎所有成熟的分布式集群——从数据库到消息队列再到协调服务——都绕不开"主节点"这个角色。主节点维护集群的"全局地图":有哪些节点、各自状态如何、数据分片如何分布、副本落在哪些节点上。这些工作如果交给每个节点各自为政,集群就会陷入"人人都是主、人人都不做主"的混乱状态。一旦发现节点失联,它负责触发副本迁移、分片重分配、副本补齐等恢复动作,把"人工救火"变成"自动愈合"。可以看到,主节点并不直接参与业务数据的读写,而是站在"控制面"上,为数据面提供路由信息、健康状态和恢复决策。

2601_96560537的博客 276
上一篇: Inside Class Loaders
下一篇: Find a way out of the ClassLoader maze (2)
DeepNightTwo
博客等级 码龄21年 3粉丝 25原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址